ListBox.EditCellAt

From Xojo Documentation

Method

ListBox.EditCellAt(row as Integer, column as Integer)

New in 2019r2

Supported for all project types and targets.

Scrolls the row, column cell into view (if necessary) and temporarily makes the cell editable. row and column are zero-based. It sets the focus within the ListBox to the row, column cell and selects its contents, if any. The editable cell has a focus ring around it.

Notes

Use the CellTypeAt or ColumnTypeAt properties to change a cell or column to “inline editable” when you want the user to be able to edit the contents of the ListBox. Then call the EditCellAt method for each cell. This gives the editable cell the focus and selects the current text of the cell, if any. Typing replaces the cell's contents. When the user presses Tab or Return or clicks in another cell, the cell loses the focus and the contents of the cell are saved (this also calls the CellAction event handler).

When a cell is editable, the ActiveTextControl property is the TextEdit that contains the contents of that cell. This may be a TextField or a TextArea depending on the specified column type. You can use this property to set or get the text of the Listbox cell, set the selection, or change other properties of the ListBox's TextField or TextArea.

Example

The following code in the CellClick event makes the cell the user pressed on editable. The parameters row and column are passed to the function.

Me.CellTypeAt(row, column) = Listbox.CellTypes.TextField
Me.EditCellAt(row, column)

This code marks an entire column as editable:

ListBox1.ColumnTypeAt(3) = ListBox.CellTypes.TextArea

In the CellClick event handler, you can then check if the column was pressed and then enable editing:

If column = 3 Then
Me.EditCellAt(row, column)
End If