PDA

Click to See Complete Forum and Search --> : Change(Maximize) the Drop Down size of a Combo Box(Drop Down list Box)


Sep 20th, 2000, 09:00 PM
For dropdown height of a combobox:

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
Procedure
Public Sub SetComboHeight(oComboBox As ComboBox, _
lNewHeight As Long)

Dim oldscalemode As Integer

' This procedure does not work with frames: you
' cannot set the ScaleMode to vbPixels, because
' the frame does not have a ScaleMode Property.
' To get round this, you could set the parent control
' to be the form while you run this procedure.

If TypeOf oComboBox.Parent Is Frame Then Exit Sub

' Change the ScaleMode on the parent to Pixels.
oldscalemode = oComboBox.Parent.ScaleMode
oComboBox.Parent.ScaleMode = vbPixels

' Resize the combo box window.
MoveWindow oComboBox.hwnd, oComboBox.Left, _
oComboBox.Top, oComboBox.Width, lNewHeight, 1

' Replace the old ScaleMode
oComboBox.Parent.ScaleMode = oldscalemode
End Sub

Usage:

Call SetComboHeight(Combo1, 1450)

And to change the dropdown width of a combobox:

Public Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Long) As Long

Public Const CB_SETDROPPEDWIDTH = &H160
Procedure
Public Sub SetComboWidth(oComboBox As ComboBox, _
lWidth As Long)

' lWidth is in pixels

SendMessage oComboBox.hwnd, CB_SETDROPPEDWIDTH, lWidth, 0

End Sub