Set ComboBox DropDown List Height

'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Add 2 ComboBoxes to your form.
'Run your program, dropdown the ComboBoxes and see the List Height difference.
'Insert this code to the module :

Public Declare Function MoveWindow Lib "user32" _
(ByVal hwnd As Long, ByVal x As Long, ByVal y As _
Long, ByVal nWidth As Long, ByVal nHeight As Long, _
ByVal bRepaint As Long) As Long

'Insert the following code to your form:

Function SetComboHeight(YourCombo As ComboBox, lDropDownHeight As Long)
Dim oldscalemode As Integer
If TypeOf YourCombo.Parent Is Frame Then Exit Function
oldscalemode = YourCombo.Parent.ScaleMode
YourCombo.Parent.ScaleMode = vbPixels
MoveWindow YourCombo.hwnd, YourCombo.Left, _
YourCombo.Top, YourCombo.Width, lDropDownHeight, 1
YourCombo.Parent.ScaleMode = oldscalemode
End Function

Private Sub Form_Load()
'Replace the 'Combo1' below with the name of the ComboBox you want to change its list height.
'Replace the '100' below with your desirable list height

SetComboHeight Combo1, 100
End Sub

Go Back