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:

     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

    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 EditModeOn or EditModeStarting event.


    Dim originalVal As String


    Private Sub FpSpread1_EditModeOn(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FpSpread1.EditModeOn


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


    End Sub


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


    Label1.Text = "New value : " + FpSpread1.ActiveSheet.ActiveCell.Value.ToString() + "Old Value = " + originalVal


    End Sub


    Regards,

Need extra support?

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

Learn More

Forum Channels