I have many controls that i make in run time and i locate them in my panel on the form,now i want to delete each control that the user selected ,how can i understand that which control has been focused ?? thanks .
Asked
Active
Viewed 2,012 times
2 Answers
5
Generally, you need FocusManager.GetFocusedElement if you are using WPF or Form.ActiveControl for WinForms.
For panel it will be:
if (panel.ContainsFocus)
{
Control currentlyFocused =
panel.Controls.Cast<Control>().FirstOrDefault(control => control.Focused);
}

kyrylomyr
- 12,192
- 8
- 52
- 79
-
i want to find on my panel,not on my form. – Farna Mar 10 '11 at 15:06
-
@na.farzane, are you using WPF or WinForms? – kyrylomyr Mar 10 '11 at 15:08