2012-10-15 36 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()'。 –

相关问题