### Refresh TableView Data

To refresh the data displayed in the tableview, after changes have been made, several
examples on HowTo.
Example 1
' Forces a table refresh by making the first column invisible and visible again
' Parameter Tableview
' Example: refreshTableView(tableviewStandard)
`Sub refreshTableView(t As TableView)
If t.ColumnsCount = 0 Then Return
t.SetColumnVisible (0,False)
t.SetColumnVisible (0,True)
End Sub`
//Note: This solution might not always work.
Example 2
For this example the tableview has the id: tableviewStandard
`Sub refeshTableViewStandard
' Get the selected row
Dim rs As Int = tableviewStandard.SelectedRow
' Use a temporary list which holds the updated row (cells) objects as taken from the updated tableview list
Dim tvl As List
tvl.Initialize
tvl.AddAll(tableviewStandard.Items)
' Clear all items in the tableview list
tableviewStandard.Items.Clear
' And add the objects from the list to the tableviewStandard items
For i = 0 To tvl.Size - 1
Dim r() As Object = tvl.Get(i)
tableviewStandard.Items.Add(Array As Object(r(0), r(1)))
Next
' Set the selected row
tableviewStandard.SelectedRow = rs
End Sub`
Example 3
Uses
Private tvwMain As TableView
' Load data from a database in a tableview
`Sub loadDatabase
Log("loadDatabase :: Start")
Try
Log(" Clear data from the tableview...")
tvwMain.Items.Clear
Log(" Load data into the tableview...")
DBUtils.ExecuteTableView(gSQL, "SELECT * FROM ", Null, 0, tvwMain)
Log(" Set column width...")
Dim w As Int = Round(tvwMain.Width / tvwMain.ColumnsCount)
For i = 0 To tvwMain.ColumnsCount - 1
tvwMain.SetColumnWidth(i, w)
Next
Log(" Table Rows / Cols:" & tvwMain.Items.Size & "/" & tvwMain.ColumnsCount)
Catch
Log(LastException.Message)
End Try
Log("loadDatabase :: End")
End Sub`

Changed: , Category: TableView, File: T6C259M1892.htm, ID: 1892