Scroll bar in checkbox list in asp.net

I am using VS 2005, in asp.net, please tell me how I can show the scrollbar in the checkboxlist after the number of items exceeds the specified. as in my situation, if they have more than 5 elements in my list of flags than the scroll bar should show .. and I do not want to correct its height, as if there were only 1 element, not just 1 point ... please , help me...

I used this, but its area takes (Hight) even their 1 or 2 elements in the list. div style = "overflow-y: auto; height: 100px"

+4
source share
2 answers

Instead of fixing the height with a static value, you can set the maximum height of the div container. In this case, it will use the automatic height if it is less than the height you specified :)

PS To make a cross browser with maximum height, you must install it as follows in your css:

.checkBoxList { max-height:100px; height:auto !important; height:100px; } 
+7
source

I used the panel like this:

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

0
source

Source: https://habr.com/ru/post/1309523/


All Articles