### Add and get Data from a TableView

This example shows how add and get data from a TableView.
There are 3 columns defined with 3 rows with following test data:
[1][1][1]
[2][4][8]
[3][9][27]
Populate the TableView with test data
' Clear all items from the tableview
tableviewStandard.Items.Clear
' Define 3 columns
tableviewStandard.SetColumns(Array As String("Column 1", "Column 2", "Column 3"))
' Set the column width for the 3 columns
tableviewStandard.SetColumnWidth(0, 100)
tableviewStandard.SetColumnWidth(1, 100)
tableviewStandard.SetColumnWidth(2, 100)
'
' Add some test date into the cells
' Add 3 rows and data into the 3 column cells
For i = 1 To 3
' Use array as object with 3 entries for columns 1 to 3
tableviewStandard.Items.add(Array As Object(i, i * i, i * i * i))
Next
Get the cell content using TableView Items property
' Get the date from the cells and show these in the log
' Using the Items property
For i = 0 To tableviewStandard.Items.Size - 1
Log("Get the content of each cell in the tableview using the Items property")
Log("Number of Columns: " & tableviewStandard.ColumnsCount)
Dim Row() As Object = tableviewStandard.Items.Get(i)
For j = 0 To Row.Length - 1
Log("Row " & i & " | Cell " & j & ", Value=" & Row(j))
Next
Next
Get the cell content using TableView SelectedRowValues property
' Get the date from the cells and show these in the log
' Using the selectedrowvalues property
For i = 0 To tableviewStandard.Items.Size - 1
Log("Get the content of each cell in the tableview using the SelectedRowValues property")
Log("Number of Columns: " & tableviewStandard.ColumnsCount)
tableviewStandard.SelectedRow = i
Dim Row() As Object = tableviewStandard.SelectedRowValues
For j = 0 To Row.Length - 1
Log("Row " & i & " | Cell " & j & ", Value=" & Row(j))
Next
Next
Output
Program started.
Get the content of each cell in the tableview using the Items property
Number of Columns: 3
Row 0 | Cell 0, Value=1
Row 0 | Cell 1, Value=1
Row 0 | Cell 2, Value=1
Get the content of each cell in the tableview using the Items property
Number of Columns: 3
Row 1 | Cell 0, Value=2
Row 1 | Cell 1, Value=4
Row 1 | Cell 2, Value=8
Get the content of each cell in the tableview using the Items property
Number of Columns: 3
Row 2 | Cell 0, Value=3
Row 2 | Cell 1, Value=9
Row 2 | Cell 2, Value=27
Get the content of each cell in the tableview using the SelectedRowValues property
Number of Columns: 3
Row 0 | Cell 0, Value=1
Row 0 | Cell 1, Value=1
Row 0 | Cell 2, Value=1
Get the content of each cell in the tableview using the SelectedRowValues property
Number of Columns: 3
Row 1 | Cell 0, Value=2
Row 1 | Cell 1, Value=4
Row 1 | Cell 2, Value=8
Get the content of each cell in the tableview using the SelectedRowValues property
Number of Columns: 3
Row 2 | Cell 0, Value=3
Row 2 | Cell 1, Value=9
Row 2 | Cell 2, Value=27

Changed: , Category: TableView, File: T6C259M1871.htm, ID: 1871