Share via


Visual Basic Reference

DblClick Event Example

This example displays a selected list item in a TextBox control when either a CommandButton control is clicked or a list item is double-clicked. To try this example, paste the code into the Declarations section of a Form object that contains a ListBox control, a TextBox control, and a CommandButton control. Then run the example and click the CommandButton control or double-click an item in the ListBox control.

  Private Sub Form_Load ()
   List1.AddItem "John"   ' Add list box entries.
   List1.AddItem "Paul"
   List1.AddItem "George"
   List1.AddItem "Ringo"
End Sub

Private Sub List1_DblClick ()
   Command1.Value = True   ' Trigger Click event.
End Sub

Private Sub Command1_Click ()
   Text1.Text = List1.Text   ' Display selection.
End Sub