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

ListBox dynamic width and static height

1 Answer 310 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 04 Mar 2015, 10:57 PM
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;
    }

1 Answer, 1 is accepted

Sort by
0
Accepted
Magdalena
Telerik team
answered on 09 Mar 2015, 09:43 AM
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.

 
Tags
ListBox
Asked by
Alexander
Top achievements
Rank 1
Answers by
Magdalena
Telerik team
Share this question
or