This is a migrated thread and some comments may be shown as answers.

Dropdown list width

3 Answers 127 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Eliyahu Goldin
Top achievements
Rank 1
Eliyahu Goldin asked on 19 Aug 2008, 05:49 PM
Is there a way to make the dropdown list width adjust to accomodate the width of the items without wrapping? Standard asp.net dropdown list does it if the width is not specified.

3 Answers, 1 is accepted

Sort by
0
Accepted
Rosi
Telerik team
answered on 20 Aug 2008, 07:19 AM
Hi Eliyahu,

You can change the width of the dropdown by using the DropDownWidth property. However RadComboBox does not support automatic change of the width according to the width of the items.


Kind regards,
Rosi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Ian Darke
Top achievements
Rank 2
answered on 30 Oct 2008, 01:54 AM
Please consider this a feature request. You should be able to determine the maximum width required for the dropdown client-side via some javascript/DOM operations.

Without this, we need to either make guesses about client font-sizes/characters or "build for the largest possible width" -- either of which is ugly.
0
Rosi
Telerik team
answered on 30 Oct 2008, 07:18 AM
Hello Ian Darke,

You can try set the width dynamically depending on the item with the widest text. Here is how:

int maxWidth = 0; 
foreach (RadComboBoxItem item in RadComboBox1.Items) 
    int itemLength = item.Text.Length; 
    if (itemLength > maxWidth) 
    { 
        maxWidth = itemLength; 
    } 
RadComboBox1.DropDownWidth = maxWidth * 7; 

I hope this helps.

Best wishes,
Rosi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ComboBox
Asked by
Eliyahu Goldin
Top achievements
Rank 1
Answers by
Rosi
Telerik team
Ian Darke
Top achievements
Rank 2
Share this question
or