A form will opens when i click on treenode. I need to set focus from treenode to the textbox control in newly opened form.
Use the
form.Activate()
method on the new form to bring it to the front, then use the
textbox.Focus()
method on your textbox.
You could try to set the ActiveControl property on the desired TextBox upon opening the newly created form: Active Control MSDN docs
Basically, you do sth like this in your load form method:
private void yourFormLoad(object sender, EventArgs e)
{
ActiveControl = yourTextBox;
}
Of course, you have to firstly focus the new form by calling the form Activate method:
yourForm.Activate()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.