Getting a value from cell

Posted by: cvetx on 8 September 2017, 1:49 pm EST

  • Posted 8 September 2017, 1:49 pm EST

    It might be a duplaicate question with others, but I am quite confused make things clear. Here is the goal.


    Goal : to get a origian value and edited value from a cell when it is edited even though the cursor has not been left the cell.


    I can think of "Leave" event, but the cursor has to leave that cell.


     Let me know.


    Thanks.

  • Replied 8 September 2017, 1:49 pm EST

    Hello,

    If you wish to return the edited values of the cell without leaving the cell, then you may achieve the same using the EditChange event. This event occurs when the user changes the text in a cell in edit mode.Below snippet might help:

    <blockquote>

     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

            FpSpread1_Sheet1.RowCount = 5
            FpSpread1_Sheet1.ColumnCount = 2
            FpSpread1.ActiveSheet.Cells(0, 0).Value = "HELLO"
     End Sub

     Private Sub FpSpread1_EditChange(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.EditorNotifyEventArgs) Handles FpSpread1.EditChange

            MsgBox(Convert.ToString(FpSpread1.ActiveSheet.Cells(0, 0).Value))

     End Sub

    </blockquote>

    After running the above snippet, you may edit the cell(0,0) contents and upon each editing the value will be returned without leaving the cell.Hope this helps.

  • Replied 8 September 2017, 1:49 pm EST

    How do I get a original value which is "Hello"? Because I need to get a original value and edited value in order to compare that is really changed or not.


     Thanks.

  • Replied 8 September 2017, 1:49 pm EST

    You may define a global level variable and set it's value in <FONT size=2>EditModeOn or <FONT size=2>EditModeStarting event. </FONT></FONT>

    <FONT size=2><FONT size=2><FONT size=2>

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Dim</FONT></FONT><FONT size=2> originalVal </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>String</FONT></FONT>

    <FONT color=#0000ff size=2><FONT color=#0000ff size=2><FONT size=2>

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Private</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Sub</FONT></FONT><FONT size=2> FpSpread1_EditModeOn(</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ByVal</FONT></FONT><FONT size=2> sender </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> System.Object, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ByVal</FONT></FONT><FONT size=2> e </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> System.EventArgs) </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Handles</FONT></FONT><FONT size=2> FpSpread1.EditModeOn


    originalVal = FpSpread1.ActiveSheet.ActiveCell.Value.ToString()


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>End</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Sub</FONT></FONT>

    <FONT color=#0000ff size=2><FONT color=#0000ff size=2><FONT size=2>

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Private</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Sub</FONT></FONT><FONT size=2> FpSpread1_EditChange(</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ByVal</FONT></FONT><FONT size=2> sender </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> System.Object, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ByVal</FONT></FONT><FONT size=2> e </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> FarPoint.Win.Spread.EditorNotifyEventArgs) </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Handles</FONT></FONT><FONT size=2> FpSpread1.EditChange


    Label1.Text = </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"New value : "</FONT></FONT><FONT size=2> + FpSpread1.ActiveSheet.ActiveCell.Value.ToString() + </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"Old Value = "</FONT></FONT><FONT size=2> + originalVal


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>End</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Sub</FONT></FONT>


    <FONT color=#0000ff size=2><FONT color=#0000ff size=2>Regards,

    </FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT>
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels