JFace: Set selection index in TableViewer

Selecting a row by index in a table viewer isn’t very straightforward. There is no method like tableViewer.setSelectionIndex.

Here is a snippet how its done:

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

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert