Click here to Skip to main content
15,900,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I set Window Form to Panel Control similar with MDI but it has matter which been setting Window Form can't get focus.

Please teach me how to set focus Window Form in Panel Control.
I can't use MDI by character of my work.

Please help me.


[orig. title]
Please, Please, Please.
Posted
Updated 12-Jan-11 2:37am
v4
Comments
Slacker007 7-Jan-11 3:15am    
Your question title was not descriptive. Please give more information to your question by clicking the "Improve quetion" link in green.
jerrykid 7-Jan-11 3:20am    
Why do you use Panel Control as MDI parent of Window Form? Why don't you use a Form and set IsMdiContainer = True in properties window. After that use this form to add MdiChildren form?
Dalek Dave 7-Jan-11 3:44am    
Minor Edit for Readability.
JangHyen 9-Jan-11 19:10pm    
I can't use a Form and set IsMdiContainer = True, Because my program must supported multi-monitor and when child is maximized, it just use one monitor not multi-monitor. And, by maximizing, child has FormBorder even if maximizing.
jerrykid 9-Jan-11 21:57pm    
Please view my new answer about this

Some links to refer:
Introduction to MDI Forms with C#[^]
http://www.geekpedia.com/tutorial41_Using-MDI.html[^]
And set focus with this code
C#
foreach (Form frm in this.MdiChildren)
            {
                if (frm.Name == "form name to set focus")
                {
                    frm.Activate();
                    break;
                }
            }
 
Share this answer
 
v2
Comments
Dalek Dave 7-Jan-11 3:45am    
Great answer.
thatraja 7-Jan-11 13:28pm    
Good answer
Non-empty forms do not get focus, they activate and go to foreground. You can call Form.Activate(). For a control you want to get in focus -- only one, call Focus().
 
Share this answer
 
Comments
Dalek Dave 7-Jan-11 3:45am    
This is true, and simple, have 5
thatraja 7-Jan-11 13:28pm    
Good answer
I think that you want to set focus to a control, but it's not appear, right? If so, please use Select() method, because the control is inside of another control, the Focus() method cannot apply to control when you standing at outside the parent control of this control. E.g,
textBox1.Select();//This code can set focus for textbox control if this textbox is inside of a control container
 
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