Get the name of the Focused element in C#

前端 未结 5 1033
甜味超标
甜味超标 2020-12-06 08:53

Is there a function in C# that can return the Name of the Focused element and display it in a text-box or something?

5条回答
  •  [愿得一人]
    2020-12-06 09:09

    Assuming WinForms, you can find the active (focused) control using the Form.ActiveControl property and get the name.

    Otherwise if this is a WPF project, you could use the FocusManager.GetFocusedElement() method to find it.

提交回复
热议问题