How to resize a scroll composite to always fit its contents horizontally?
Asked Answered
M

1

3

I have a scrolled composite ,it contains a tableViewer. My requirement is that if the table is increased in width,the scroll composite should not show horizontal scroll ,but it should expand to fit table's size. The only reason I have used a scrolled composite here is I want to show vertical scroll bar.

Mon answered 13/10, 2011 at 5:23 Comment(0)
B
5

If you want to control the scrollbars of a Table in SWT - which is a sub-class of Scrollable - simply add one or more of the following styles in the constructor. If you construct a Viewer, the same styles are used.

SWT.H_SCROLL

Style constant for horizontal scrollbar behavior

SWT.V_SCROLL

Style constant for vertical scrollbar behavior

SWT.NO_SCROLL

Style constant for no scrollbar behavior

When neither H_SCROLL or V_SCROLL are specified, controls are free to create the default scroll bars for the control. Using NO_SCROLL overrides the default and forces the control to have no scroll bars.

Bergen answered 13/10, 2011 at 7:10 Comment(2)
My problem is when I resize the table the parent copmosite is not resizing accordingly,but it is trimming the table ie it doesnot show full table.Mon
What is the used layout of the parent Composite? Consider use GridLayout and a GridData(FILL, TOP, true, false) for the table itself.Bergen

© 2022 - 2024 — McMap. All rights reserved.