How to Force a DropDown and Retract of the List in a Combo BoxLast reviewed: June 21, 1995Article ID: Q124057 |
The information in this article applies to:
- Standard and Professional Editions of Microsoft Visual Basic for Windows, versions 2.0 and 3.0 SUMMARY This article shows you how to send a message to the Combo box to force the List portion to drop or retract at any time. Usually, to drop the List portion of a Combo box, you click the dropdown button located to the right of the Combo's edit box, or you can press the F4 key when the control has the focus. To have the Combo box retract the List portion, you click the dropdown button again, use the mouse or keyboard to choose an item from the list, press the ESC or F4 key, or click anywhere else on the screen.
MORE INFORMATIONTo send the CB_SHOWDROPDOWN message to a Combo box of Style 0 - Dropdown Combo or 2 - Dropdown List, call the SendMessage API function. If the wParam parameter is any non-zero integer, the List will drop. If wParam equals 0, the List will retract. Note that a Combo box of Style 1 (Simple Combo) always has its list visible.
Step-by-Step Example
NotesIf the form is moved or resized while the List is down, the List will not move with the form. To make it behave like the standard Combo Box, add the following code to the Form's paint and resize events to force the retraction of the list:
Sub Form_Paint () x% = SendMessage(combo1.hWnd, CB_SHOWDROPDOWN, 0, 0&) End Sub Sub Form_Resize () x% = SendMessage(combo1.hWnd, CB_SHOWDROPDOWN, 0, 0&) End SubYou don't have to do this, if you want the List to be always on top, even when the form is moved or resized. The List can be retracted only by clicking the "Rectract" Button or choosing an item from the list.
|
Additional reference words: 2.00 3.00 ComboBox
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |