Combo box [message #665555] |
Fri, 15 April 2011 01:23  |
Eclipse User |
|
|
|
Hi All,
I hv three combo boxes in a section.I have two items in the 1st combo box. When i select an item in 1st combo box , the second combo box should disappear but when I select another item from the 1st combo box the second combo should appear. How can i do it?? i tried adding listener and setting the visibility to false depending on th eselection. but the layout goes for a toss. is there any other way??
Thanks
Madhu
|
|
|
|
|
|
|
Re: Combo box [message #666348 is a reply to message #665555] |
Wed, 20 April 2011 00:54   |
Eclipse User |
|
|
|
final Label l1= toolkit.createLabel(composite,
"C1");
final CCombo c1= new CCombo(composite,
SWT.DROP_DOWN | SWT.BORDER);
c1.setItems(new String[] { "A", "B" });
final GridData gridData = new GridData(SWT.FILL, SWT.CENTER,
true, false, 1, 1);
c1.setLayoutData(gridData);
final Label l2= toolkit.createLabel(composite,
"C2");
final CCombo c2 = new CCombo(composite, SWT.DROP_DOWN
| SWT.BORDER);
final GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false, 1,
1);
c2.setLayoutData(gd);
Label l3= toolkit.createLabel(composite,
"C3");
CCombo c3 = new CCombo(composite, SWT.DROP_DOWN
| SWT.BORDER);
final GridData objgd = new GridData(SWT.FILL, SWT.CENTER,
true, false, 1, 1);
c3.setLayoutData(objgd);
c1.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
selectedText = c1.getText();
if (selectedText.equalsIgnoreCase("A")) {
gd.exclude = true;
l2.setVisible(false);
c2.setVisible(false);
composite.layout(true);
With the above snippet, the layout is not proper.
Label appears in one line and drop down in the next line. should i recreate the composite?
[Updated on: Wed, 20 April 2011 03:43] by Moderator
|
|
|
Re: Combo box [message #667501 is a reply to message #666348] |
Fri, 29 April 2011 04:22  |
Eclipse User |
|
|
|
As your label 'l2' needs to disapear as well as the combo 'c2', try to create and add a gridData to l2.
Update the exclude field to true as you did it for combo gridData.
|
|
|
Powered by
FUDForum. Page generated in 0.99302 seconds