Click to See Complete Forum and Search --> : Opening a new form from a TreeView


Gunship919
04-25-2006, 06:02 PM
I have a TreeView that I use to navigate to a new form. In an AfterSelect event method for the TreeView I use the following code to open the new form:

XPMApp.Detail = new DetailForm(this);
XPMApp.Detail.Show();
XPMApp.Detail.Focus();

The problem is that the new form opens and flashes in front on me, but focus goes back to/stays with the 1st form, and specifically the selected treeview.

Any idea how to set the focus properly? Am I using the wrong event handler?

Gunship919
04-25-2006, 06:42 PM
Found the answer to this issue on MSDN forums:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=220134&SiteID=1

The key is to use the MouseMove event, since it fires last.
Hope this helps anyone with a similar issue!

Spencer