I cannot correctly set DropDownHeight from ComboBox to display all elements.
I am using a control that inherits from ComboBox. I overridden the OnDrawItem and OnMeasureItem methods to create multiple columns and text wrapping in the column, if necessary. All of this works great.
The problem occurs when I try to install DropDownHeight. I set DropDownHeight to an arbitrarily large value, which was slightly larger than the list of items. The ComboBox control automatically disables any value for DropDownHeight that is larger than the size of all displayed items in the list. (Assuming you have a MaxDropDownItems property that is larger than the number of elements, which I do.) This behavior usually works fine, as shown below:
alt text http://www.freeimagehosting.net/uploads/dd09404697.png
No, this is not my real data in the drop-down list.
The problem occurs when I have an entry in the drop-down list that I need to wrap in order to display the full text. This entry is displayed normally, but, however, the ComboBox calculates DropDownHeight, it ignores the fact that one of the entries is twice as high as usual, so you need to scroll one line to go to the last entry in the drop-down list.
alt text http://www.freeimagehosting.net/uploads/d0ef715f83.png
This is the code I use to determine if an element is needed to wrap text and to set the height of each element:
Protected Overrides Sub OnMeasureItem(ByVal e As System.Windows.Forms.MeasureItemEventArgs)
MyBase.OnMeasureItem(e)
Dim tmpStr As String = FilterItemOnProperty(Items(e.Index), "OptionDescription")
Dim lng As Single = e.Graphics.MeasureString(tmpStr, Me.Font).Width
Dim HeightMultiplier As Integer = Math.Floor(lng / _ColumnWidths(1)) + 1
e.ItemHeight = e.ItemHeight * HeightMultiplier
End Sub
I cannot determine how to make the DropDownHeight property be exactly the value I want, or how to tell the ComboBox manager that one (or more) of the items in the list is above normal.
Override Shadow the DropDownHeight, , , .
EDIT:
WPF, ? ( WPF, ?)