2

I have and Add button and TableViewer in my application. When the Add button is pressed, I'm adding a new element to my model, then refreshing that viewer.

The question is: How to select this newly added item in my viewer?

Lii
  • 11,553
  • 8
  • 64
  • 88
execc
  • 1,083
  • 12
  • 25

1 Answers1

6
tableViewer.setSelection(new StructuredSelection(modelElement), true);

The true at the end will make the table scroll to the newly selected item, if necessary.

Frettman
  • 2,251
  • 1
  • 13
  • 9