DesktopListBox.EditCellAt

From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!
Method

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

New in 2021r3

Supported for all project types and targets.

Scrolls the row, column cell into view (if necessary) and temporarily makes the cell editable. It sets the focus within the DesktopListBox 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 DesktopListBox. 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 DesktopTextControl that contains the contents of that cell. This may be a DesktopTextField or a DesktopTextArea depending on the specified column type. You can use this property to set or get the text of the DesktopListbox cell, set the selection, or change other properties of the DesktopListBox's TextField or TextArea.

Example

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

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

This code marks an entire column as editable:

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

In the CellPressed 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