Background: I am doing some UI work in an eclipse environment where I fill a combo control with some values. The string values have an different length and often a length greater than the combo width and the width of the parent composite.
Problem: When I open the dropdown list, the width of the list is greater than the width of the parent composite and the user could not see the complete value of the list entry.
I have tried to use the "setTextLimit" option, but without success. For me it is perfectly adequate if I could set the width of the dropdon list with a constant value.
Code example:
this.mComponentName = new Combo (lComponentComposite, SWT.BORDER);
this.mComponentName.setTextLimit(COMBO_TEXT_LIMIT);
GridData componentNameGridData = new GridData();
componentNameGridData.widthHint = 166;
this.mComponentName.setLayoutData(componentNameGridData);
this.mComponentName.addSelectionListener(this.mComboSelectionAdapter);
this.mComponentName.addKeyListener(this.mComboKeyAdapter);
Greetings dirk
A drop-down list is a list in which the selected item is always visible, and the others are visible on demand by clicking a drop-down button. A combo box is a combination of a standard list box or a drop-down list and an editable text box, thus allowing users to enter a value that isn't in the list.
While creating a combobox specify Horizontal scroll also
this.mComponentName = new Combo (lComponentComposite, SWT.BORDER|SWT.H_SCROLL);
This will not let the text overflow
That is really a good question. After digging through developer forums and even the source code, I lean towards saying it is not possible.
I solved the problem temporarily by switching to a CCombo
, but I do not like the solution as I believe one of SWT's strength is in using native widgets, and the CCombo
does not look as good (at least on Win7 and OS X).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With