gpt4 book ai didi

java - 如何将 TableViewer 中的选择设置为指定索引?

转载 作者:行者123 更新时间:2023-12-02 13:25:08 25 4
gpt4 key购买 nike

我的 RCP 应用程序的 view 中有一个 TableViewerTableViewer 有一个对象List 作为输入。是否可以使用我设置为 TableViewer 输入的列表中对象的索引来对特定对象进行选择?例如,我想在每次打开应用程序时将默认选择设置为第三个对象。如何设置该选择?

最佳答案

找到答案了!

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

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

关于java - 如何将 TableViewer 中的选择设置为指定索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12889423/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com