Solution: Problem of focus when opening a Winform using Treeview node click
I must blog this , since I could not find the fix as quickly as I should. So…
When you try to open a winform using treeview node selection (using any event like mouse_click on after_select) , the form opens, but it remains minimized even if you have set the focus and windowstate properties. That is because treeview regains control after opening form, however there is no direct fix. You can fix it by delaying the action of the event.
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
this.BeginInvoke(new TreeViewEventHandler(delayedClick), sender, e);
private void delayedClick(object sender, TreeViewEventArgs e)
// your code goes here…
Original solution here.