Listbox cells not edible

I would like to be able to type text in into the cells of the 1st and 2nd column of a listbox, but I can only do this in the first column with this code. Why is that?

//Make listbox cells editable
winmain.ListBoxRelations.ColumnTypeAt(0) = ListBox.CellTypes.TextField
winmain.ListBoxRelations.ColumnTypeAt(1) = ListBox.CellTypes.TextField

This allows me to edit any Cell from any Column:

Sub DoubleClick() Handles DoubleClick
  // Allows the user to Edit the Row,Cell where the DoubleClick was done !
  Var Row, Column As Integer
  // Get the Row,Column where the user clicked
  Row    = Me.RowFromXY(gX,gY)
  Column = Me.ColumnFromXY(gX,gY)
  // Edit the Cell at x,y
  Me.CellTypeAt(Row, Column) = ListBox.CellTypes.TextField
  Me.EditCellAt(Row, Column)
  EditON = True
End Sub

Are you trying to move using the Tabulator Key from Column 1 to Column 2 or are you clicking twice in Column 2? I am asking because Xojo does not automatically add the “logic” needed to tell the Listbox what should happen if you press a Key within a Cell.

I tried both, but the 2nd column cell is not clickable.

“Why are you excluding it ?”

Seriously, check where you placed code to exclude the editing for Column 1… (Comumn 1 is 2nd Column…)

I don’t have code anywhere to exclude the editing of these columns. Not sure why I would use it in this case…

Not sure too, but the code I shared comes from a running project.

Create a new Project, add a DesktopListBox, add 10 Rows/5 Columns, the code to edit and run… to be sure.

1 Like

Is it possible you mix DesktopListbox and Listbox or in other Words Xojo API 1 and Xojo API 2?
And i assume you have the below Code in the Opening Event of this DesktopListbox, correct?

//Make listbox cells editable
winmain.ListBoxRelations.ColumnTypeAt(0) = DesktopListBox.CellTypes.TextField
winmain.ListBoxRelations.ColumnTypeAt(1) = DesktopListBox.CellTypes.TextField

winmain.ListBoxRelations.ColumnTypeAt(0) = DesktopListBox.CellTypes.TextField

I can’t say why this should create such an effect, but strange things can happen if you mix both API’S. :person_shrugging:

I’ve created an empty project using Xojo 2023r4 / API2, and I am ablt-e to Edit Column 1 (2nd Column)…

So, the error is in your code / project.

Listbox cells not edible

I would say it’s much better so for your health. Not a lot of nutritions in a listbox cell. :laughing:
Sorry, couldn’t resist.



Ulrich was just pointing a mistype/mistake

In 2023r4 it does not allow

And here API 2 works

1 Like

Not sure what the error was. I also created an empty project for testing and I was able to type into the cells. I fixed to by deleting the listbox and added a new one with another name. All is well! Thanks all.

1 Like

Can you please mark this Thread as solved? Thank you :slight_smile:

1 Like

No, both were Listbox objects, not desktopLisbox. Thanks.

1 Like

Done! :grinning:

1 Like