Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding out which control has focus

Is there a way to figure out which control in my visualtree has focus? This is mostly for debugging.

like image 794
Perry Avatar asked Nov 10 '11 09:11

Perry


People also ask

What is a control focus?

Focus is a low-level method intended primarily for custom control authors. Instead, application programmers should use the Select method or the ActiveControl property for child controls, or the Activate method for forms.

Which property of a form returns the control that is currently in focus?

You can use this property to determine whether a control or any of the controls contained within it has the input focus. To determine whether the control has focus, regardless of whether any of its child controls have focus, use the Focused property.


1 Answers

Like this

bool FocusedElement = FocusManager.GetFocusedElement() == textBox;

Use FocusManager

like image 191
Sai Kalyan Kumar Akshinthala Avatar answered Sep 24 '22 15:09

Sai Kalyan Kumar Akshinthala