CF - Set Focus to a specific control
Posted
by no9
on Stack Overflow
See other posts from Stack Overflow
or by no9
Published on 2010-06-10T08:42:34Z
Indexed on
2010/06/10
8:52 UTC
Read the original article
Hit count: 501
Hi !
I have a Form that has a panel with some textBoxes and checkBox that is outside the panel. Every time the Form is loaded the checkBox has focus.
I have put en event handler when form loads and tried to set focus on first textbox instead having it on the checkbox.
this.Activated += new EventHandler(form_Activated);
in the method i try to set the focus on the first textbox in the panel
private void form_Activated(object sender, EventArgs e)
{
if (this.parametersPanel.Controls.Count > 0)
{
this.parametersPanel.Focus();
(this.parametersPanel.Controls[0]).Focus();
}
}
This does not work, can some1 help me pls?
© Stack Overflow or respective owner