how to find out which textbox is currenlty selected.

Posted by abcdefghijklmnopqrstuvwxyz on Stack Overflow See other posts from Stack Overflow or by abcdefghijklmnopqrstuvwxyz
Published on 2011-02-09T11:40:32Z Indexed on 2011/02/09 15:25 UTC
Read the original article Hit count: 148

Filed under:

I have 3 text-boxes, how do I find out which text-box is currently selected (has focus). I am unable to come up with anything.

Public Class Form1
    Public activeTextBox As TextBox = CType(Me.ActiveControl, TextBox)
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        activeTextBox.Text = activeTextBox.Text & "This is text 1"
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        activeTextBox.Text = activeTextBox.Text & "This is the text 2"
    End Sub
End Class

enter image description here

© Stack Overflow or respective owner

Related posts about vb.net