Scrollbar in checkbox list in asp.net
Asked Answered
S

2

5

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 "

Smacker answered 12/5, 2010 at 7:43 Comment(0)
C
8

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;
}
Clinkstone answered 12/5, 2010 at 7:52 Comment(0)
P
0

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;
}

Result

Pompei answered 5/12, 2016 at 11:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.