문제

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?

도움이 되었습니까?

해결책

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

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top