Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Listbox Resize Automatically
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01454537
Message ID:
01454580
Views:
21
>>>>>I have a listbox in a table on my page. When I run the app, the listbox is sized to fit the 3 items in the list, not the size I created it
>>>>>in design time.
>>>>>
>>>>>What's the deal here?
>>>>
>>>>How did you size it? If you set Rows=3 then it should work......
>>>
>>>I didn't do anything with Rows. This is all I have done with the listbox:
>>>
>>>
>>>private void _LoadList()
>>>{
>>>    DataLayer.ProviderInvariantName = "System.Data.SqlClient";
>>>    DataLayer.ConnectionString = ConfigurationManager.ConnectionStrings["ApexGlobalConnectionString"].ConnectionString;
>>>
>>>    dsRoles = DataLayer.ExecuteQuery("as_GetRole", CommandType.StoredProcedure);
>>>
>>>    lstRoles.DataSource = dsRoles.Tables[0];
>>>    lstRoles.DataTextField = "RoleName";
>>>    lstRoles.DataBind();
>>>}
>>>
>>>
>>>
>>>When I run it, it's height is much smaller than in design time.
>>
>>I thought you said you set it at design time ? Anyway:
lstRoles.Rows = dsRoles.Tables[0].Rows.Count;
>
>ya, but what if I don't want the size to change. This code you provided is what I'm already seeing, except I'm nto doin that anywhere.
>I'd like the listbox to be a fixed height.
>
>
>[UPDATE]
>Here's the problem
>
>
><asp:ListBox ID="lstRoles" Height="100%" Width="100%" runat="server" AutoPostBack = "true" OnSelectedIndexChanged="lstRoles_SelectedIndexChanged"></asp:ListBox>
>
>
>Changed it to
>
><asp:ListBox ID="ListBox1" Height="200" Width="100%" runat="server" AutoPostBack = "true" OnSelectedIndexChanged="lstRoles_SelectedIndexChanged"></asp:ListBox>
>
If you want a fixed number of rows it's better to set the number of rows rather than an explicit height. e.g:
><asp:ListBox ID="ListBox1" Rows="3" Width="100%" runat="server" AutoPostBack = "true" OnSelectedIndexChanged="lstRoles_SelectedIndexChanged"></asp:ListBox>
Previous
Reply
Map
View

Click here to load this message in the networking platform