ListBox scrollbar alignment


I have been working with the ListBox control and found that the vertical scrollbar does not match the listboxes MinimumHeight property.
To reproduce
1: Create a window
2: Create a ListBox add it to window and add a number of items to it so when it resizes smaller the vertical scroll bar appears
3: set MinimumHeight of ListBox to 0
4: Position listbox along left side of window with 20 pixel gap between top and bottom of listbox then set anchor of listbox to left | top | bottom
5: Run program and slowly resize the window vertically smaller and smaller so that it makes the height of the listbox shorter.
The listbox will continue to reduce in height or until it meets the inherited Control.MinimumHeight value. But you will notice that the vertical scroll bar within the listbox is going off of it's own MinimumHeight value and it does not decrease in size beyond a certain point. The problem comes in when the listbox is resized down to a smaller size then what the scroll bar can resize down to and when you resize the listbox back up to a larger size the scrollbar is no longer anchored properly inside the listbox and usually the scroll down button on the scroll bar is clipped off and you are not able to click on it.
A simple fix to this is to add the fallowing code to ListBox.cs ...
    public override int MinimumHeight
        get { return base.MinimumHeight; }
            base.MinimumHeight = value;
            if (this.sbVert != null) this.sbVert.MinimumHeight = value;


grimston wrote Apr 6, 2013 at 6:19 AM

Fixed as of change set 31568

wrote May 16, 2013 at 10:22 AM

wrote May 16, 2013 at 10:22 AM

wrote Jun 14, 2013 at 7:19 AM