omega
omega

Reputation: 43833

How to get currently focused TextBox?

How can I get the ID of the TextBox which is currently focused? If none is focused, it should return a null value.

Note: It should only check text boxes.

Upvotes: 1

Views: 1118

Answers (1)

Dev
Dev

Reputation: 367

TextBox focusedTxt = Controls.OfType<TextBox>().FirstOrDefault(x => x.Focused);

Upvotes: 3

Related Questions