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

[Solved] RadCombobox width

3 Answers 318 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Ashwin Deshpande
Top achievements
Rank 1
Ashwin Deshpande asked on 06 Aug 2009, 07:33 AM
is there any property in RadCombobox..which i can set it takes the Max length of characters in the list....
I do nto want to set the widthin Pizels or percentage..

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 06 Aug 2009, 10:05 AM
Hi Ashwin,

I hope you want to trim the RadComboBoxItems showing in the dropdown when it exceeds a particular length. If so, one suggestion would be trimming the text explicitly as shown below. You can  set the Tooltip property so that user can see the full text if it is not completely visible in items text.

C#:
 
protected void Page_Load(object sender, EventArgs e) 
    foreach (RadComboBoxItem item in RadComboBox1.Items) 
    { 
        if (item.Text.Length > 6) 
        { 
            item.ToolTip = item.Text; 
            item.Text = item.Text.Substring(0, 6).ToString() + ".."
        } 
    } 

-Shinu.
0
Ashwin Deshpande
Top achievements
Rank 1
answered on 30 Aug 2009, 10:30 AM
Shinu,

Thanks for answer,but this is not th oen I am Looking forward to.
Example:-- i Have 4 Items in RadCombobox.
RadC
RadCCC
RadCCCCC
RadCCCCCCC

I want the RadCombobox width to be set Dynamically(according to max length of items) as in Case of dropdownlist.

Ashwin
0
Kamen Bundev
Telerik team
answered on 31 Aug 2009, 08:36 AM
Hi Ashwin,

There's currently no default and supported way to do that.

You eventually can do that with javascript by getting the text in the OnSelectedIndexChanged event, render it in a block element somewhere out of the screen, while applying the RadComboBox input styles to the block, measuring the width of the resulting block and then applying this width it to the RadComboBox.

Greetings,
Kamen Bundev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
ComboBox
Asked by
Ashwin Deshpande
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Ashwin Deshpande
Top achievements
Rank 1
Kamen Bundev
Telerik team
Share this question
or