ListBox dynamic width and static height

2 posts, 1 answers
  1. Alexander
    Alexander avatar
    67 posts
    Member since:
    Jun 2014

    Posted 04 Mar 2015 Link to this post

    Hey everyone,

    I have a RadListBox with a few RadListBoxItems inside it. They have varying text where some are pretty small while others can be large. I would rather set the width of the RadListBox to the width of the largest length text while also setting a defined static height.

    I have set the width with CSS like so:
    .RadListBox_Default
        {
            width:auto !important;
        }

    That part works great on its own. But if I add a static height to either the CSS to make it look like:
    .RadListBox_Default
        {
            width:auto !important;
            height:300px;
        }
    or straight to the ascx, the RadListBox messes up. The width becomes 2 pixels and the RadListBox becomes unusable.

    I was wondering if there was a way to get the width to be dynamic while having the height be static. Any help/thoughts are appreciated, thanks!


    .RadListBox_Default
        {
            width:auto !important;
        }

    .RadListBox_Default
        {
            width:auto !important;
        }

    .RadListBox_Default
        {
            width:auto !important;
        }

  2. Answer
    Magdalena
    Admin
    Magdalena avatar
    421 posts

    Posted 09 Mar 2015 Link to this post

    Hello Alexander,

    Thank you for contacting Telerik support.

    Please, set the render mode of RadListbox to lightweight and apply the following CSS code to your project to achieve the described behavior:

    aspx
    <telerik:RadListBox runat="server" ID="RadListBox1" Height="100px" RenderMode="Lightweight" >

    CSS
    html .RadListBox .rlbGroup {
        overflow-x: hidden;
    }
     
    html .RadListBox .rlbItem {
        padding-right: 20px;
    }


    Do not hesitate to contact us if you have other questions.


    Regards,
    Magdalena
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top