Microsoft KB Archive/93215

= Making Enter Key in Directory List Box Act Like Double-Click =

Article ID: 93215

Article Last Modified on 8/16/2005

-

APPLIES TO


 * Microsoft Visual Basic for MS-DOS
 * Microsoft Visual Basic 1.0 Standard Edition
 * Microsoft Visual Basic 2.0 Standard Edition
 * Microsoft Visual Basic 3.0 Professional Edition

-



This article was previously published under Q93215



SUMMARY
When 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 INFORMATION
The 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 Sub If 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 Sub Additional reference(s):

Chapter 18, &quot;Using the File-System Controls&quot; of the &quot;Microsoft Visual Basic for Windows Programmer's Guide&quot;

Chapter 10, &quot;Using the File-System Controls&quot; of the &quot;Microsoft Visual Basic for MS-DOS Programmer's Guide&quot;

Additional query words: 1.00 2.00 3.00

Keywords: KB93215

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.