'Declarations
'Paste this into the declarations section of a module 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 'Notes 'Use this sub where you like: it does not have to be 'in the combo's dropdown event. Also, this code 'will not work if you specify a width that is less 'than the width of the combo box control. i.e. you 'can only make the drop down list part of the control ' wider that the control itself. This sub sends a message to a combo box, setting the width of the drop down area. It is only a wrapper for the SendMessage API function. Pass it the combo box, and the new width, and it will send the appropriate message. |