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

RadListBox - Set width dynamically depending on Text of Item

1 Answer 319 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Nayan
Top achievements
Rank 1
Nayan asked on 29 Feb 2012, 02:51 PM
Hello,

By default every item text gets wrapped if its longer than width of RadListBox.
How to set width of RadListBox dynamically based on text of item. Basically I want to expand width of RadListBox, without wrapping text of item.
In below example, 3rd item gets wrapped automatically. I want to expand RadListBox in a way that it can fully accommodate 3rd item without wrapping or scroll bar.
 
  <telerik:RadListBox
        runat="server" ID="RadListBoxSource"
        Height="200px">
        <Items>
            <telerik:RadListBoxItem Text="China" Value="1"/>
            <telerik:RadListBoxItem Text="Egypt" Value="1"/>
            <telerik:RadListBoxItem Text="England England England England England England England England England" Value="1"/>
            <telerik:RadListBoxItem Text="France" Value="1"/>
        </Items>
    </telerik:RadListBox>

Appreciate any help.

Thanks
Paresh

1 Answer, 1 is accepted

Sort by
0
Bozhidar
Telerik team
answered on 01 Mar 2012, 12:43 PM
Hi Paresh,

You can do that simply by adding the following CSS:
.RadListBox_Default
{
    width:auto !important;
}

If you use some skin, change the selector, so that instead of Default it says the skin name. For instance, if you use the Forest skin, it should look like:
.RadListBox_Forest
{
    width:auto !important;
}
 
Regards,
Bozhidar
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ListBox
Asked by
Nayan
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Share this question
or