2012-10-15 70 views
1

我在我的RCP應用程序的view中有TableViewerTableViewerListobjects作爲輸入。是否可以使用我設置爲TableViewer的輸入的列表中的對象的索引爲特定對象創建selection?例如,我想在每次打開我的應用程序時爲第三個對象設置默認選擇。我如何設置選擇?如何將TableViewer中的選擇設置爲指定的索引?

回答

7

找到答案!

int selection = 5; //row we want to select 
tableViewer.setSelection(new StructuredSelection(tableViewer.getElementAt(selection)),true); 

感謝http://andy.ekiwi.de/?p=1040

+0

+ 1,但請記得首先調用'tv.getTable()。setFoucs()'。 –

相關問題