TableViewer's Horizontal Scrollbar [message #737066] |
Fri, 14 October 2011 16:09 |
|
Hi all,
I have a TableViewer that contains only 1 column and I want it to have the following behavior:
1. When the content width is less than the TableViewer's width, the column should occupy all the remaining space.
2. When the content width exceeds the TableViewer's width, a horizontal scrollbar should be drawn to enable user to see the entire content.
It seems that I can not have the above behavior at once.
For 1st behavior I've added the following:
...
Composite tableContainer = toolkit.createComposite(parent);
tableContainer.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
tableContainer.setLayout(new TableColumnLayout());
TableViewer tableViewer = ...
TableViewerColumn tableViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
((TableColumnLayout)tableContainer.getLayout()).setColumnData(tableViewerColumn.getColumn(), new ColumnWeightData(100, ColumnWeightData.MINIMUM_WIDTH, false));
...
Which works fine as shown by 1st screenshot.
But I'm still missing the 2nd behavior (2nd screenshot), so I add the following after TableViewer#setInput:
...
tableViewer.getTable().getColumns()[0].pack();
...
This works fine for very long content (3rd screenshot), but not for short content (4th screenshot).
I might have done things improperly here so any help would be appreciated.
Thanks & Regards,
Setya
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03158 seconds