JavaFX FXML : Select 并从 TableView 的多个单元格中获取值
JavaFX FXML : Select and get values from multiple cells of TableView
是否可以只选择单个单元格而不是表格视图中的整行?可以在同一列上完成多个单元格选择。
您不能直接在 FXML 中执行此操作,但您可以在控制器中执行此操作:
// allow selection of individual cells (instead of entire rows):
tableView.getSelectionModel().setCellSelectionEnabled(true);
// allow selection of multiple cells at once:
tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
要获取选定的单元格值,您可以按照
是否可以只选择单个单元格而不是表格视图中的整行?可以在同一列上完成多个单元格选择。
您不能直接在 FXML 中执行此操作,但您可以在控制器中执行此操作:
// allow selection of individual cells (instead of entire rows):
tableView.getSelectionModel().setCellSelectionEnabled(true);
// allow selection of multiple cells at once:
tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
要获取选定的单元格值,您可以按照