Setting the Height of a ComboBox Control
.NET Framework 1.1 does not provide a way to change the height of a combobox control. This can be achieved by sending CB_SETITEMHEIGHT
with −1 as index to the combobox control:
Private Declare Auto Function SendMessage Lib "user32.dll" ( _
ByVal hWnd As IntPtr, _
ByVal wMsg As Int32, _
ByVal wParam As IntPtr, _
ByVal lParam As IntPtr _
) As IntPtr
Private Const CB_ERR As Int32 = -1
Private Const CB_SETITEMHEIGHT As Int32 = &H153
Private Function SetComboBoxEditHeight( _
ByVal ComboBox As ComboBox, _
ByVal Height As Integer _
) As Boolean
Return _
SendMessage( _
ComboBox.Handle, _
CB_SETITEMHEIGHT, _
New IntPtr(-1), New IntPtr(Height) _
) <> New IntPtr(CB_ERR)
'ComboBox.Refresh()
End Function
Usage:
Debug.Assert(SetComboBoxEditHeight(Me.ComboBox1, 50))