### Select multiple Rows

To set the TableView to multiselection mode, this can be accomplished by using API methods (requires the JavaObject library).
API References:
https://docs.oracle.com/javafx/2/api/javafx/scene/control/TableView.html
https://docs.oracle.com/javafx/2/api/javafx/scene/control/TableView.TableViewSelectionModel.html
Define Global JavaObjects
Private tvwMain As TableView
Dim joTvw As JavaObject 'TableView as JavaObject
Dim joSelectionModel As JavaObject 'TableView selection model
...
End Sub
Set the TableView Selectionmodel to Multiple
'Set the cell selection to false to ensure rowselection
tvwMain.SingleCellSelection = False
'Assign the tableview to the JavaObject
joTvw = tvwMain
'Get the Selection Mode Enum
Dim joSelectionMode As JavaObject
joSelectionMode.InitializeStatic("javafx.scene.control.SelectionMode")
'Define a JavaObject as TableView and set the selectionmode by using the enum
joTvw.RunMethodJO("getSelectionModel", Null).RunMethod("setSelectionMode", Array(joSelectionMode.RunMethod("valueOf", Array("MULTIPLE"))))
'Capture the selectionmodel to set row selected and obtain selectionstate for a row
joSelectionModel = joTvw.RunMethodJO("getSelectionModel", Null)
'Set few rows to selected (for tests)
joSelectionModel.RunMethod("select",Array(1))
joSelectionModel.RunMethod("select",Array(2))
joSelectionModel.RunMethod("select",Array(6))
'List the selected rows - show only the first cell (r(o))
'Loop over all rows and use IsSelected
`Sub ListRowsSelected
Dim isSelected As Boolean
For i = 0 To tvwMain.Items.Size - 1
isSelected = joSelectionModel.RunMethod("isSelected", Array(i, Null))
If isSelected Then
Log("Row " & i & " = " & isSelected)
Dim r() As Object = tvwMain.Items.Get(i)
Log(r(0))
End If
Next
End Sub`
'List the selected rows - show only the first cell (r(o))
'Get the selected rows as observable list
`Sub ListRowsSelected2
'Get selected rows from table as list
Dim l As List
l.Initialize
l.AddAll(joSelectionModel.RunMethodJO("getSelectedItems",Null))
'Log the selected data from a row. Each list entry is an object
Log(l.Size)
For Each r() As Object In l
Log(r(0))
Next
End Sub`

Changed: , Category: TableView, File: T6C259M1894.htm, ID: 1894