How to Programmatically Display or Hide a VB Combo Box ListLast reviewed: June 21, 1995Article ID: Q85991 |
The information in this article applies to:
SUMMARYThe list of a Visual Basic drop-down combo box (Style=0 or 2) is usually opened and closed by using a mouse. However, you can also open and close the list of a combo box programmatically by using the Windows SendMessage function as described below. However, there is an easy way. In visual basic, when a drop-down combo box has the focus, you can press ALT-DOWN to open it up. Therefore, you can use SendKeys to send these keys to the combo box, as in this example: To do this programmatically, use the following code to change focus to the combo box and send the necessary keystroke:
combo1.SetFocus SendKeys "%{Down}" MORE INFORMATIONThe CB_SHOWDROPDOWN constant can be used with the SendMessage function to programmatically open or close the list of a Visual Basic drop-down combo box of Style=0 or Style=2 (Style=1 always has the list displayed). The following steps demonstrate how to open the list of a drop-down combo box:
NOTE: The list of a combo box with Style=0 or 2 will close when the combo box loses focus.
|
Additional reference words: 1.00 2.00 3.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |