RowSet.ColumnCount
From Xojo Documentation
Read-Only Property (As Integer )
The number of columns in the RowSet.
Sample Code
The following method populates a ListBox with a RowSet. Is uses ColumnCount to create the header for the ListBox with the names of the columns in the table:
Sub PopulateListBox(dataList As Listbox, rs As RowSet)
If rs Is Nil Then Return
// set up listbox state for population
dataList.RemoveAllRows
// Add the DB columns as the headers for the ListBox
dataList.ColumnCount = rs.ColumnCount
dataList.ColumnAt(0).WidthExpression = "100"
For i As Integer = 0 To rs.ColumnCount
dataList.Heading(i) = rs.ColumnAt(i).Name
Next
// Add the data from the table
While Not rs.AfterLastRow
dataList.AddRow("")
For i As Integer = 0 To rs.ColumnCount
dataList.CellValueAt(dataList.LastAddedRowIndex, i) = rs.ColumnAt(i).StringValue
Next
rs.MoveToNextRow
Wend
End Sub
If rs Is Nil Then Return
// set up listbox state for population
dataList.RemoveAllRows
// Add the DB columns as the headers for the ListBox
dataList.ColumnCount = rs.ColumnCount
dataList.ColumnAt(0).WidthExpression = "100"
For i As Integer = 0 To rs.ColumnCount
dataList.Heading(i) = rs.ColumnAt(i).Name
Next
// Add the data from the table
While Not rs.AfterLastRow
dataList.AddRow("")
For i As Integer = 0 To rs.ColumnCount
dataList.CellValueAt(dataList.LastAddedRowIndex, i) = rs.ColumnAt(i).StringValue
Next
rs.MoveToNextRow
Wend
End Sub