To reproduce this problem,
- Create a new WinForms project
- Using the WinForms designer, add a
SplitContainer
- Set its orientation to horizontal
- Set its dock to fill
- In each of the containers of the
SplitContainer
, add aListBox
- Set its dock to fill
- Increase its font size so that the behaviour in question can be observed more clearly
- Add a few items to the list boxes
After those steps, the designer should look like this:
- Now run the program
- Resize the containers in the
SplitContainer
You should see that with some sizes of the upper container, there will be a space between the two list boxes (sorry for my bad mouse-writing).
For other sizes of the upper container, there is little to no space.
I hypothesized that this is because list boxes can't show "half an item" so it reduces its size to not show that half of an item. Is this true?
I have thought of the following solution:
Restricting the resizability of the split container so the user can only resize in "steps" where each step is equal to the height of one item in the list box.
However, I don't quite like this because when the item height is large, the user experience feels unnatural (at least to me).
How can I make it so that the list boxes resize properly (i.e. leaving no gaps)?