ListBox.Cell


Warning

This item was deprecated in version 2019r2. Please use DesktopListBox.CellTextAt as a replacement.

Description

Used to read from or write to the Cell based on the row and column numbers passed.

Notes

row and column are zero-based. The top-left Cell is 0,0. Passing -1 as either the Row or Column number means all rows or all columns, respectively. For example, the following specifies all columns in the last row added using AddRow or InsertRow:

Me.Cell(Me.LastIndex, -1)

If you set this equal to a tab-delimited string, you can update the row with one line of code.

Sample code

This example copies all cells from one ListBox into another:

ListBox2.Cell(-1, -1) = ListBox1.Cell(-1, -1)

The destination listbox will have the same number of rows and columns as the source. Header data is not transferred.

In this example, the following code populates a two-column ListBox with the names of the controls in the window and their indexes.

Dim i As Integer
For i = 0 To Self.ControlCount - 1 ' number of controls in window
  ListBox1.AddRow(Str(i)) ' first column
  ListBox1.Cell(Listbox1.LastIndex, 1) = Control(i).Name ' second column
Next

Compatibility

All projects types on all supported operating systems.