Deborah's Developer MindScape

         Tips and Techniques for Web and .NET developers.

January 26, 2010

ASP.NET: ListBox Scrollbar

Filed under: ASP.NET,C#,VB.NET @ 9:46 pm

This one is in the category of obvious once you know how to do it. But having done Silverlight of late, I could not recall how to turn on the scrollbar in a ASP.NET ListBox. There is no scrollbar property of any kind.

A bit of "guess and check" with Bing provided lots of custom control solutions, which were more than I wanted to do for one little list box.

So I finally just tried Intellisense to see what properties and methods were available. And there was a Rows property and it worked!

To turn on the scrollbar in a ListBox, just set the Rows property to the number of items to display. If  there are more than the defined number of items in the list, the scrollbar will automatically appear.


<asp:ListBox id="LB" runat="server"

The result appears like this:


The Listbox displays the first 6 items as per the Rows property. Since there are 8 items, it automatically displays the scrollbar.


RSS feed for comments on this post. TrackBack URI

Leave a comment

© 2022 Deborah's Developer MindScape   Provided by WPMU DEV -The WordPress Experts   Hosted by Microsoft MVPs