ListBox Cell changed

This topic is from 2014. Do you know if there is something new to know when a cell changed its text by code?

Do it on your own.

  • Subclass Listbox
  • Create an Event definition “CellChanged” (CellTextChanged already exists)
  • Override “CellTextAt” and Raise your event

Rem Listbox1 // show changes API 2 R.3.1

Function CellKeyDown(row as Integer, column as Integer, key as String) Handles CellKeyDown as Boolean
rem up / down
If key = Chr(30) And row > 0 Then
oldtext = Listbox1.CellTextAt(row,column)
oldpos = New point(row-1,column)
Me.EditCellAt(row-1,column)
End If
If key = Chr(31) And row < listbox1.RowCount -1 Then
oldtext = Listbox1.CellTextAt(row,column)
oldpos = New point(row+1,column)
Me.EditCellAt(row+1,column)
End If
End Function

Function CellPressed(row As Integer, column As Integer, x As Integer, y As Integer) Handles CellPressed as Boolean
rem cellsave
oldtext = Listbox1.CellTextAt(row,column)
oldpos = New point(row,column)

Me.EditCellAt(row,column)

End Function

Sub SelectionChanged() Handles SelectionChanged
If oldpos <> Nil Then
label1.Text =oldtext +" -select-
"+Listbox1.CellTextAt(oldpos.x,oldpos.y)
Else
label1.Text = “NEW”
End If

End Sub

Properies:
oldpos as Point
oldtext AS string

Thank you Stefan. In fact I wanted something without subclassing, but I see that many people subclasses this control to provide with more features. It’s a pity that after so many years and the new implementations for the control, they only have an event when you change the text with the keyboard and not with the code. I have created a “Feature request” for this. (<https://xojo.com/issue/67390>)

Rudolf, thank for your comments, but they are focused on using the keyboard, and this is precisely what I wanted to avoid.