Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an MDI form which contains a tree (docked left) which acts as a menu for opening MDIChild forms. When i click on a node of the tree (in NodeMouseClick event), a new MDIChild form is opened. The problem is that it does not receive the focus. The focus always remains on the tree. The MDIChild form does not have a Title and is maximized within the parent MDI form.

What I have tried:

I have tried using .Focus, Activate, BringToFront on the MDIChild form without any luck.

Is there a solution to this problem? Using .NET 4.0.3.
Posted
Updated 8-May-19 8:34am
v3
Comments
[no name] 8-May-19 15:22pm    
The child order may not be what you think it is.

https://social.msdn.microsoft.com/Forums/vstudio/en-US/7294a7d8-c85c-44d8-b491-bc13c2500182/focus-mdi-child?forum=csharpgeneral
Member 10622063 8-May-19 15:41pm    
It's not a matter of ordering. The first form that opens when i click on a node in the treeview, does not receive the focus as it should. The focus remains on the treeview on the MDI form, as if the treeview steels it.
[no name] 8-May-19 22:49pm    
What's your "click" handler? The face-palm is usually that e.Handled is not set to true, causing the "default" behavior you see.
Member 10622063 9-May-19 3:40am    
NodeMouseClick. No e.Handled there...
Richard MacCutchan 8-May-19 16:53pm    
It would help if you showed the code that sets the focus.

1 solution

Wow! After a lot of searching in the last couple of days, i stumbled onto this: Tree control focus frustration | PC Review[^]

The proposal in the final post worked!

Thanks to everyone for the assistance.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900