ListBox AutoSizes by item height

Mo3r picture Mo3r · May 9, 2012 · Viewed 13.2k times · Source

I use TableLayoutPanel for all my elements in a form. I use Dock Fill to autosize a TextBox and a ListBox. TextBox fits perfectly in a cell of the TableLayoutPanel but not a ListBox. It autosizes by item height.

enter image description here

How to delete this gap between the bottom of the ListBox and the bottom of the form? I know I can set the height of the ListBox by a certain value (e.g. item height in the ListBox is 16, 16 * 10 elements= 160, 160 will fit correctly), but is there any other solutions?
I'm using C#.

Answer

LarsTech picture LarsTech · May 9, 2012

Set the ListBox's property IntegralHeight = false; so that it won't resize the control by the item height variable.