C# Bugs ListBox
Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio
The Problem
Docking a ListBox - whether on a form or a panel - can be quite frustrating the first time round!
Create a new project, insert a ListBox on the form, and then fill dock the ListBox.
Notice that when you resize the form the ListBox appears to undock itself from the bottom part of the form.
The Solution
The problem is caused by the ListBox trying to ensure that only complete items can be seen - this is why the ListBox jerks from one height to another when you resize the form. The solution is simply to tell it to forget about having only whole items. This is done setting the IntegralHeight property to false
Once this is set you can resize the form to any size and the ListBox will always remain at the same padding distance from the bottom of the form.




