ListBox CellTextAt update in CellAction event

I am updating a cell value in the CellAction event of a DesktopListBox. After the cell value has been updated, if I refer to the cell text in the same event, it still returns the old value. How can I refer to the new value (without using a variable)?

Var OldVal As String
OldVal = Me.CellTextAt(0,0) // let's say OldValue = 1
// change cell value
Me.CellTextAt(0,0) = "2"
// refers to old value even though value has changed

I intially thought it may be because the cell text change does not register until cell has lost focus. But if I print the value in the CellFocusLost event, it still refers to the old value.

At this point, the listbox CellTextAt has not yet been updated with the value from ActiveTextControl.Text. Update that instead. You may need to update both, depending on your needs.

When you edit a cell, the system creates a TextBox for you (you can specify your own if you wish). While that textbox is active, the listbox cell contains the original value. Only after the edit process is complete is the textbox value copied back into the cell. It can be tricky.

1 Like