Custom Self-Expanding MultiSelect Winforms ListBox


Server Intellect Web Hosting Solutions


Custom Self-Expanding MultiSelect Winforms ListBox

Author: Peter A Bromberg

Unfortunately, the Windows Forms ComboBox class doesn't support multiple selections. Only the ListBox does.The problem with the ListBox is that if you set its height to a single item, you have to use the little up/down arrows at the right to move through the list of items, and you only get to see one of the items at a time. If you set its height big enough to show all the items, well -- there goes your real estate. What I did is to create a CustomListBox control derived from ListBox, and override its OnMouseEnter and OnMouseLeave events to automatically expand the height to exactly show all the items, allowing multiple selections, automatically sending all other controls to the back so that they don't interfere with the "view". When you are finished selecting OnMouseLeave, everything is restored to its original compact, one-line height.










More Tutorials

Also See:

Extending the datagrid control
Highlighting Multiple Search Keywords in ASP.NET
Build a TreeView Control in Less Than Two Minutes with Visual Studio 2005 Beta 2
What's Really Wrong with Remoting
Get ViewState out of the Page for a Performance Boost
Custom Paging for TableAdapters without using SPs
Maintain Control State in ASP.NET 2.0
Enterprise Library Caching Application Block
Building Date Aware Web Applications in ASP.NET
Paging and Sorting Report Data



Copyright© 2005 ASP Intellect | All Rights Reserved

ASP.NET Tutorials
AspNet Tutorials ASP.NET 2.0 Code Examples, Snippets and Tutorials

ASP.NET Tutorials C++ Tutorials C# Tutorials Visual Studio.NET Tutorials
.NET Framework Tutorials Mobility Tutorials Office Tutorials Visual Basic.NET Tutorials