[RESOLVED] Single event for multiple controls
TextBox1
TextBox2
TextBox3
TextBox4
ListBox1
I have a list box with 10 items. I want that when the user focuses on any of those texboxes and double clicks on any item in the listbox, it inserts the selected value in the focused textbox.
Can anyone help me please?
Re: Single event for multiple controls
When you double-click an item in the ListBox the TextBox will lose focus, so you are going to have to use a class-level variable to remember which TextBox was the last one to have focus.
VB Code:
Private lastFocusedTextBox As TextBox
Private Sub RememberSelectedTextBox(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Enter, _
TextBox2.Enter, _
TextBox3.Enter, _
TextBox4.Enter, _
TextBox5.Enter, _
TextBox6.Enter, _
TextBox7.Enter, _
TextBox8.Enter, _
TextBox9.Enter, _
TextBox10.Enter
Me.lastFocusedTextBox = DirectCast(sender, TextBox)
End Sub
Private Sub ListBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick
Me.lastFocusedTextBox.Text = Me.ListBox1.GetItemText(Me.ListBox1.SelectedItem)
End Sub
Re: Single event for multiple controls
wow.. thanks!!!!! I really appreciate it