Platforms to show: All Mac Windows Linux Cross-Platform
FAQ.How to handle tab key for editable cells in listbox?
Answer:
Use code like this function:
Example
Function HandleTabInList(list as listbox, row as Integer , column as Integer , key as String ) As Boolean // Handle tab character in Listbox.CellKeyDown event Select case asc(key) case 9 if Keyboard.AsyncShiftKey then // back // look for column left for i as Integer = column-1 downto 0 if list.ColumnType(i) >= list.TypeEditable then list.EditCell(row, i) Return true end if next // not found, so look in row before row = row - 1 if row >= 0 then for i as Integer = list.ColumnCount-1 downto 0 if list.ColumnType(i) >= list.TypeEditable then list.EditCell(row, i) Return true end if next end if else // forward // look for column right for i as Integer = column+1 to list.ColumnCount-1 if list.ColumnType(i) >= list.TypeEditable then list.EditCell(row, i) Return true end if next // not found, so look in row below row = row + 1 if row < list.ListCount then for i as Integer = 0 to list.ColumnCount-1 if list.ColumnType(i) >= list.TypeEditable then list.EditCell(row, i) Return true end if next end if end if end Select End Function
You call it from CellKeyDown event like this:
EventHandler Function CellKeyDown(row as Integer, column as Integer, key as String) As Boolean
if HandleTabInList(me, row, column, key) then Return true
End EventHandler
As you see in the code, we handle tab and shift + tab for moving back and forward. Also we wrap to previous/next row if needed. Feel free to extend this to wrap from last to first row or create a new row for editing.