sharkyenergy
sharkyenergy

Reputation: 4173

Detect if element with focus is a textbox

How can I detect if the active element in my VB.NET app is a Textbox?

Me.ActiveControl and then?

Upvotes: 1

Views: 1226

Answers (2)

Gonzix
Gonzix

Reputation: 1206

Another way would be

If Me.ActiveControl.GetType() Is GetType(System.Windows.Forms.TextBox) Then 
    ' do stuff
End If

Upvotes: 1

user2480047
user2480047

Reputation:

You can use TypeOf:

Dim isATextBox As Boolean = TypeOf Me.ActiveControl Is TextBox

Upvotes: 1

Related Questions