Listbox Question

I have a quick question about Listboxes. I have seen examples where a control, such as a textfield, radiobuttons, checkbox, textarea, button, etc. has been placed in a cell in a listbox. If this can be done, how can this done dynamically using code? Can you provide some code examples?

Any help will be greatly appreciated.

Thanks very much,

Gary

The support fof TextArea, textFields and checkboxes is built into the listbox… See the docs.

For Radiobuttons ,popupmenus and other controls you would need to draw and manage yourself in the cell*paint and other events.

Have you watched Pauls Webinar on list boxes?

For checkboxes and edit fields change the CellType property of the cell.

e.g. this adds a row to a listbox, sets the cell to editable type, and then makes the cell temporarily editable (using EditCell.)

MyListBox.AddRow("Hello!") MyListBox.CellType(MyListBox.LastIndex, 0) = ListBox.TypeEditable MyListBox.EditCell(MyListBox.LastIndex, 0)

Other controls like radio buttons or push buttons will be quite a bit more work but still possible.

If you haven’t already, check out the “Using the ListBox” webinar from last month along with its accompanying example projects.

http://documentation.xojo.com/index.php/Videos

[quote=37706:@Andrew Lambert]For checkboxes and edit fields change the CellType property of the cell.

e.g. this adds a row to a listbox, sets the cell to editable type, and then makes the cell temporarily editable (using EditCell.)

MyListBox.AddRow("Hello!") MyListBox.CellType(MyListBox.LastIndex, 0) = ListBox.TypeEditable MyListBox.EditCell(MyListBox.LastIndex, 0)

Other controls like radio buttons or push buttons will be quite a bit more work but still possible.[/quote]

Andrew. Thanks. And thanks to all the replies. I did watch the video and it did answer part of my question. Andrew, you mention that other controls such as radio buttons and push buttons are possible, but require a bit more work. Can you elaborate on this? I have a need to put several different types of controls in a listbox.

Again, thanks for your insight.

Gary

I’m not Andrew, but I’ll elaborate: besides TextField/Area and Checkbox, you cannot put any other controls into a ListBox cell. However, with careful use of the CellBackgroundPaint, CellTextPaint event handlers, you can draw a representation of the control in the cell. And in conjunction with the CellClick, MouseDown, MouseUp event handlers you can make the control react to user interaction.

The “popup” menu in the ListBox (and its example) from the Webinar is an example of one way you might go about this.

@Paul Lefebvre beat me to the punch! :slight_smile: