RadListBox - Set width dynamically depending on Text of Item

2 posts, 0 answers
  1. Paresh
    Paresh avatar
    2 posts
    Member since:
    Feb 2012

    Posted 29 Feb 2012 Link to this post

    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
  2. Bozhidar
    Admin
    Bozhidar avatar
    1103 posts

    Posted 01 Mar 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top