CIOC
CIOC

Reputation: 1427

SWT table with fixed height

I have a simple SWT table like this, with an initial height of 60px:

Table table = new Table(parent, SWT.BORDER | SWT.FULL_SELECTION);
GridData gd_table = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
gd_table.heightHint = 60;
table.setLayoutData(gd_table);
table.setHeaderVisible(true);

I'm programmatically adding rows, when a new row is added the height of the table is increased messing with the rest of the UI, is there a way to set a fixed height to the table and maybe adding a scrollbar when the rows doesn't fit the table height?

Upvotes: 1

Views: 4615

Answers (1)

Baz
Baz

Reputation: 36884

If you don't want the Table to fill up the available vertical space, then tell the GridData not to do it:

GridData gd_table = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);

should do it.


As for the scrollbar, simply add SWT.V_SCROLL to the style of the Table.

Upvotes: 4

Related Questions