2016-11-16 58 views
-1

与选择table row类似,我们可以自动选择tableviewtableviewJavaFX吗?在javafx中自动选择一个表格列表

自动,我的意思是,如果我按down arrow key,只single column需要进行选择,而不是一个all columns of single row

感谢

+1

你需要说明你的意思。你的意思是你想要选择一列中的单个单元格还是全部单元格?表格由行,列和单元格组成,您需要明确说明您要选择的内容。对我来说,听起来你想为特定的列选择所有的单元格,但当按下“向下箭头键”时没有意义。 –

+0

我更新了我的问题 – UVM

+0

请问'table.getSelectionModel()。setCellSelectionEnabled(true);'完成你想要的吗?它允许您选择单个单元而不是整行。 –

回答

2

,如果你选择模型的cellSelectionEnabled属性设置为true,你能选择单个单元格。

使用箭头键可以将选择选项移动到由箭头确定的聚焦细胞方向旁边的单元格。

// selection for single cells instead of single 
table.getSelectionModel().setCellSelectionEnabled(true); 

// select third cell in first (possibly nested) column 
table.getSelectionModel().clearAndSelect(2, table.getVisibleLeafColumn(0)); 

// focus the same cell 
table.getFocusModel().focus(2, table.getVisibleLeafColumn(0)); 
+0

对不起,它为我工作。不过,我对代码进行了一些更改以使其工作,因为我需要专注于第一列。 – UVM

+0

我刚刚修改了我的答案。 – UVM

相关问题