Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i'm creating a project. there i first created a parent form. then i loaded 2 panels and in the parent form.
and i created a 3 forms with different functionality.
i successfully loaded form1 in panel1. i need to load a form in panel2 when a button is clicked in form1 that is loaded in panel1.
please help me to complete this.
thanks in advance...,
Posted
Updated 25-Aug-12 16:33pm
v2
Comments
[no name] 25-Aug-12 22:25pm    
Well from your very vague description you want Form2 frm2 = new Form2(); frm2.Show(); or ShowDialog().
prabah.02 25-Aug-12 22:31pm    
this is not working..,
i want to load a form in panel...,
when i click a button in form1(loaded in panel1) a form needs to load in panel2
[no name] 25-Aug-12 22:40pm    
That makes no sense. You are not going to be loading a form in a panel. You probably mean you want to load a user control?

 
Share this answer
 
Comments
Mohamed Mitwalli 26-Aug-12 1:39am    
5+
nitin bhoyate 26-Aug-12 5:42am    
thanks go ahead.....Keep coding...
Mohamed Mitwalli 26-Aug-12 6:02am    
lol thanks for advice
loading form inside panel
inside button's click event, write code as below
C#
form2 frm = new form2();
frm.Toplevel = false;
pnl2.controls.add(frm);
frm.show();

Happy Coding!
:)
 
Share this answer
 
v2
Comments
Mohamed Mitwalli 26-Aug-12 6:00am    
Top-level control cannot be added to control Well this is the Error
message will appear your missing this line of code
frm.TopLevel = false ;
So i voted 1
Aarti Meswania 26-Aug-12 9:01am    
oh! yes really it is.
that line is very important else whole code is meaning less.
thanks for your honest decision-downvoting!
:)
Mohamed Mitwalli 26-Aug-12 9:13am    
But unfortunately people not reading the answers or the comment another solution has been added with the same Error :(
Aarti Meswania 26-Aug-12 9:27am    
hmm,
I have 'improve solution' of our both.
so, ok now?
Mohamed Mitwalli 26-Aug-12 9:45am    
yes Thanks :)
C#
panl2.controls.clear();

form2 frm = new form2();
frm.TopLevel = False;
pnl2.controls.add(frm);
frm.show();
 
Share this answer
 
v3
Comments
Mohamed Mitwalli 26-Aug-12 9:15am    
Top-level control cannot be added to control Well this is the Error message will appear your missing this line of code frm.TopLevel = false ; So i voted 1
Could you in the next time Read the Solution that provide by other developer maybe it will help you .
Aarti Meswania 26-Aug-12 9:41am    
hi! one line was missing here so, I have added it using 'improve solution' link
line was 'frm.TopLevel = false;',
because, form is default top level control so, if we don't write this line it will give error.

now, both of our solutions are working!
that is good effort to answer question. keep it up.
:)

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