WebListBox

From Xojo Documentation


For desktop applications, see ListBox.

Class (inherits from WebControl)

A scrollable, multicolumn listbox control that is similar to the desktop Listbox control.

Events
CellClick HeaderPressed SelectionChanged


Properties
AlternateRowColor HasHeading MultiLine
CellTag HeaderStyle PrimaryRowColor
ColumnCount Heading RowCount
ColumnHeaderStyle LastIndex fa-lock-32.png RowHeight fa-lock-32.png
ColumnWidth List SelectionStyle
ColumnWidths ListIndex
DataSource MinimumRowHeight


Methods
AddRow ColumnStyle RowTag
Cell DeleteAllRows ScrollTo
CellPicture InsertRow Selected
CellStyle RemoveRow

Notes

The WebListBox provides many of the features of the desktop Listbox.

Use the CellStyle and ColumnStyle methods to add style information to selected cells and/or columns. This is the way to change the borders, font size and style, background, opacity, and other styling attributes of WebListboxes. See the WebStyle entry for more information on the features that can be added via Web Styles.

Example

This example adds 100 rows to a 5-column listbox:

For row As Integer = 1 To 100
Listbox1.AddRow("Col1", "Col2", "Col3", "Col4", "Col5")
Next

If you want to select individual cells in the ListBox, you can do so using WebStyles. First, create a WebStyle (call it SelectedCellStyle) and set its Background to blue and its Text Color to white (or other colors of your own choosing).

In the SelectionChanged event handler for the ListBox, disable the selected row to prevent the selection from hiding the cell style:

If Me.ListIndex >= 0 Then
// Turn off row selection to allow cell style to appear
Me.Selected(Me.ListIndex) = False
End If

In the CellClick event handler, apply the SelectedCellStyle to the cell that was clicked:

// Clear all cell styles so only the selected cell is styled
For r As Integer = 0 To Me.RowCount - 1
For c As Integer = 0 To Me.ColumnCount - 1
Me.CellStyle(r, c) = Nil
Next
Next

// Set style for selected cell
Me.CellStyle(row, column) = SelectedCellStyle

See Also

DataSource, WebStyle, WebPicture classes