-
OK if I have a combo box and then contents of that combo box are filled by a DB, and when the contents are filled and you click on the combo box at run time the combo box cuts off anything that is wider than itself. Is there a way without widening the combo box that I could have the combo boxes' white part (You know when you click on it the contenst have a white background) automatically adjst to the size of the widest line in the combo box?
-
You mean, set the dropdown width of the combobox?
Change the Public to Private if you want to use in the form declarations.
Code:
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
Public Sub SetComboWidth(oComboBox As ComboBox, _
lWidth As Long)
' lWidth is in pixels
SendMessage oComboBox.hwnd, CB_SETDROPPEDWIDTH, lWidth, 0
End Sub
-
<?>
No, the textwindow of the combo box is part of the combo box and you cannot widen it without widening the combo box itself.
-
So would I then call the function?
-
Code Above
Code:
Usage
'Call SetComboWidth(Combobox, width)
Call SetComboWidth(Combo1, 500)
And it will make the white part bigger, but keep the combobox the same size.
This, therefore, proves HeSaidJoe wrong, who perhaps, tried to prove me wrong at first.
In conclusion, I am right! I am always right! :D
-