[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] limiting tree control height with formlayout

Hi all,

I am having difficult limiting the height of a tree control with FormLayout. The code is below:

Tree dbTree = getWidgetFactory().createTree(composite, SWT.SINGLE | SWT.V_SCROLL);
fDBTreeViewer = new TreeViewer(dbTree);
formData = new FormData();
formData.left = new FormAttachment(0, 0);
formData.right = new FormAttachment(100, 0);
formData.top = new FormAttachment(0, 0);
// formData.bottom = new FormAttachment(100, 0);
final int NUM_ROWS = 10;
FontMetrics fontMetrics = FigureUtilities.getFontMetrics(parent.getFont());
formData.height = fontMetrics.getHeight() * NUM_ROWS;
dbTree.setLayoutData(formData);


I set the auto expand for the viewer to 2. If there are many items at this level then the tree control becomes very tall and looks ridiculous. (The tree control is part of a section within a TabbedPropertySheet).

As you can see I do set the height of the formData to 10 * font height, but that doesn't seem to do anything. If I don't set auto expand to 2, then with just 1 root element, the tree control is ridiculously short, perhaps only 2 rows tall. Uncommenting out the line where formData.bottom is set appears to make little difference either.

How can I set the height of the tree control to consistently be 10 rows tall?

Thanks in advance,

Matt D.