Reputation: 14285
i am using VS 2005, in asp.net please tell me how can i show scroll bar in checkboxlist after the number of item count goes beyond the specified. like my situation that if their exist more then 5 items in my checkbox list than it should show a scroll bar.. and i dont want to fix its height like if their is only 1 item than it should take space of 1 item only.... please help me...
i have used this but its taking space (Hight) even their is 1 or 2 items in list.. div style="overflow-y :auto; height :100px "
Upvotes: 5
Views: 16113
Reputation: 125
I used a Panel this way:
HTML:
<asp:Panel ID="checkBoxPanel" runat="server" CssClass="scrollingControlContainer">
<asp:CheckBoxList ID="chblCustomers" runat="server"></asp:CheckBoxList>
</asp:Panel>
.Filling Method
chblCustomers.Items.Add("CK");
chblCustomers.Items.Add("Tommy");
chblCustomers.Items.Add("C&A");
chblCustomers.Items.Add("CK");
chblCustomers.Items.Add("Tommyyyyyyyyyyyyy");
chblCustomers.Items.Add("C&A");
chblCustomers.Items.Add("CK");
And its CSS:
.scrollingControlContainer
{
overflow-x: auto;
overflow-y: scroll;
}
Upvotes: 0
Reputation: 12221
Instead of fixing the height with a static value, you can set the max-height of the container div. In this case it will use auto height as long as it's less than the height you specified :)
P.S. To make the max-height cross-browser compatible, you have to set it as follows in your css:
.checkBoxList {
max-height:100px;
height:auto !important;
height:100px;
}
Upvotes: 8