### Get or set TableView Cell Content

To get or set the value of a cell in a TableView, the usage of subroutines is helpful.
' Set the content of a cell in the TableView
' Parameter Tableview
' Parameter Row in range 1 to number of tableview rows
' Parameter Col in range 1 to number of cells
' Parameter Value which holds the new value
`Sub setTableViewCell(tv As TableView, row As Int, col As Int, value As String)
' Check if row is in tableview range. Note to check starting 1
If (row < 1) OR (row > tv.Items.Size) Then Return
' Get the selected row as object. IMPORTANT is to decrease the row by 1 to start from 0
row = row - 1
Dim rowcontent() As Object = tv.Items.get(row)
' Check if the cell is in row range
If (col < 1) OR (col > rowcontent.Length) Then Return
col = col - 1
' Assign a new value to column 2 (=col with index 1, called row(1)
rowcontent(col) = value
End Sub`
' Get the content of a cell in the tableview
' Parameter Tableview
' Parameter Row in range 1 to number of tableview rows
' Parameter col in range 1 to number of cols
' Returns the value of the col
`Sub getTableViewCell(tv As TableView, row As Int, col As Int) As String
' Check if row is in tableview range. Note to check starting 1
If (row < 1) OR (row > tv.Items.Size) Then Return
' Get the selected row as object. IMPORTANT is to decrease the row by 1 to start from 0
row = row - 1
Dim rowcontent() As Object = tv.Items.get(row)
' Check if the col is in row range
If (col < 1) OR (col > rowcontent.Length) Then Return
col = col - 1
' Assign a new value to column 2 (=col with index 1, called row(1)
Return rowcontent(col)
End Sub`
Example usage
' Change the value of row 2, cell 1
setTableViewCell(tableviewStandard, 2, 1, "Moin")
' Need to refresh the data in the tableview - see How to refresh data of a TableView
tableviewStandard_Refresh
Log(getTableViewCell(tableviewStandard, 2, 1))

Changed: , Category: TableView, File: T6C259M1885.htm, ID: 1885