2016-11-16 60 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

相關問題