Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Combo box (Combo box )
Combo box [message #665555] Fri, 15 April 2011 05:23 Go to next message
Madhushree  S is currently offline Madhushree SFriend
Messages: 20
Registered: September 2010
Junior Member
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 #665560 is a reply to message #665555] Fri, 15 April 2011 05:57 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Use a GridLayout and the set the GridData.exclude = true and relayout
the parent composite.

Tom

Am 15.04.11 07:23, schrieb Madhu:
> 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 #666147 is a reply to message #665555] Tue, 19 April 2011 11:00 Go to previous messageGo to next message
Madhushree  S is currently offline Madhushree SFriend
Messages: 20
Registered: September 2010
Junior Member
Hi Tom,
I added a listener to the 1st combo box.Whenever I select the 1st item in the 1st combo box , i do gd.exclude=true. But nothing happens and did u mean creating the parent composite again for relayouting. is there a tutorial /article on this?

Thanks
Madhu
Re: Combo box [message #666154 is a reply to message #666147] Tue, 19 April 2011 11:17 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Am 19.04.11 13:00, schrieb Madhu:
> Hi Tom,
> I added a listener to the 1st combo box.Whenever I select the 1st item
> in the 1st combo box , i do gd.exclude=true. But nothing happens and did
> u mean creating the parent composite again for relayouting. is there a
> tutorial /article on this?
>
> Thanks
> Madhu

if you are not calling parent.layout(true) after having set the
gd.exclude=true nothing will change. Beside setting exclude you should
also set the visible=false as well.

Tom
Re: Combo box [message #666346 is a reply to message #665555] Wed, 20 April 2011 04:36 Go to previous messageGo to next message
Madhushree  S is currently offline Madhushree SFriend
Messages: 20
Registered: September 2010
Junior Member
Thanks Tom. I'm able to exclude the 2nd combo box. but the 3rd combo box layout goes for a toss. the label is on one line and drop down is on the next line. after setting gd.exclude=true, parent.layout=true i set horizontalSpan also. But the layout is not ok.

Thanks,
Madhu
Re: Combo box [message #666348 is a reply to message #665555] Wed, 20 April 2011 04:54 Go to previous messageGo to next message
Madhushree  S is currently offline Madhushree SFriend
Messages: 20
Registered: September 2010
Junior Member
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 07:43]

Report message to a moderator

Re: Combo box [message #667501 is a reply to message #666348] Fri, 29 April 2011 08:22 Go to previous message
Mathieu Garcia is currently offline Mathieu GarciaFriend
Messages: 14
Registered: March 2011
Location: Tououse, France
Junior Member
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.
Previous Topic:Question on using a Javascript HTML Editor in a Browser widget
Next Topic:SWT Widget handle on linux+GTK
Goto Forum:
  


Current Time: Thu Mar 28 14:49:28 GMT 2024

Powered by FUDForum. Page generated in 0.03985 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top