Making Enter Key in Directory List Box Act Like Double-ClickLast reviewed: June 21, 1995Article ID: Q93215 |
The information in this article applies to:
SUMMARYWhen you double-click an item in a directory list box control, it opens the directory and displays its subdirectories. The directory list box control ignores the Enter key by default. To cause a directory list box to treat the Enter key the same way as a double-click, set the Path property to List(ListIndex) from within the KeyPress event handler.
MORE INFORMATIONThe following code shows how to cause a directory list box to open the selected directory when the user presses the ENTER key. This code causes a Change event, just as when you double-click an item.
Sub Dir1_KeyPress (KeyAscii As Integer) If KeyAscii = 13 Then Dir1.Path = Dir1.List(Dir1.ListIndex) End If End SubIf your form contains a command button with the Default property set to True, pressing the ENTER key clicks the command button instead of firing the KeyPress event. In this case, set the Path property to List(ListIndex) from within the button Click event handler. For example:
Sub Command1_Click () Dir1.Path = Dir1.List(Dir1.ListIndex) End SubAdditional reference(s): Chapter 18, "Using the File-System Controls" of the "Microsoft Visual Basic for Windows Programmer's Guide" Chapter 10, "Using the File-System Controls" of the "Microsoft Visual Basic for MS-DOS Programmer's Guide"
|
Additional reference words: 1.00 2.00 3.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |