Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Setting visible items count in Combo dynamically(Setting visible items count in Combo dynamically)
Setting visible items count in Combo dynamically [message #541329] Sun, 20 June 2010 07:24 Go to next message
Supreetha H R is currently offline Supreetha H RFriend
Messages: 2
Registered: June 2010
Junior Member
We have a requirement to set the visible items count in combo dynamically depending on the screen resolution and the size. So that the visible items in the combo will always fit in the screen with both the ends of the combo visible with scroll buttons. Can anyone tell me if this could be done and how?
Re: Setting visible items count in Combo dynamically [message #541729 is a reply to message #541329] Tue, 22 June 2010 11:07 Go to previous messageGo to next message
Lakshmi P ShanmugamFriend
Messages: 279
Registered: July 2009
Location: India
Senior Member
Hi Supreetha,

You could compute the number of items and set it to the combo using setVisibleItemCount().

You can do something like this:
Rectangle rect = display.getClientArea();
int itemCount = rect.height/combo.getItemHeight();
combo.setVisibleItemCount(itemCount);

If you want the dropdown items to be shown only below the combo then you can compute it based on the position of the combo.
Point point = display.map(null, combo, rect.width, rect.height);
itemCount = (point.y - combo.getTextHeight())/combo.getItemHeight();

HTH,


Lakshmi P Shanmugam
Re: Setting visible items count in Combo dynamically [message #542843 is a reply to message #541729] Sat, 26 June 2010 17:32 Go to previous message
Supreetha H R is currently offline Supreetha H RFriend
Messages: 2
Registered: June 2010
Junior Member
thanku
Previous Topic:Disable editing checkboxes in a Table
Next Topic:How to disable key binding Ctrl+i in StyledText control
Goto Forum:
  


Current Time: Tue Apr 16 10:56:55 GMT 2024

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

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

Back to the top