Scroll NatTable programmatically

社会主义新天地 提交于 2019-12-11 01:54:19

问题


First question on stackoverflow ;-)

Similar question to here, only I am trying to scroll a NAT-Table programmatically. I can neither show a selected Item, nor set a value to the Scrollbar itself (via getHorizontalBar or similar).

The internet wields no answers, as far as I could see, and solutions suggested for other swt controls do not seem to apply...


回答1:


That depends on what you are trying to achieve. Do you want to select a cell and move it into the viewport, or do you simply want to move cells into the viewport without selection?

For simply moving cells into the viewport you should try the corresponding commands to achieve this:

  • ShowRowInViewportCommand
  • ShowColumnInViewportCommand
  • ShowCellInViewportCommand

    natTable.doCommand(new ShowRowInViewportCommand(gridLayer.getBodyLayer(), 50));

To achieve selection and moving a row into the viewport, you could use the corresponding selection commands:

  • SelectRowsCommand
  • SelectColumnCommand
  • SelectCellCommand

    natTable.doCommand(new SelectRowsCommand(gridLayer.getBodyLayer(), 0, 50, false, false));

Note that you need to consider the position/index transformations, which means the above statement will select the 51 row in the grid because of the column header.



来源:https://stackoverflow.com/questions/17593049/scroll-nattable-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!