Hello guys !
I have 2 form and 3 UserControl(Campain_Overview , Campain_Post, Campain_Interact).
1 - MainForm contain panel2 hold UserControl name Campain_Overview, In this UserControl contain button call "Add Campain".
2 - When I click on "Add Campain" Button, It's show another form diaglog call "Add Campain".This form contain 2 button : "Campain Post" and "Campain Interact".
3 - So I want If I click on button "Campain Post", It's close "Add Campain" form, then load userControl Campain_Post into panel2 in Mainform.
4 - Similar to button "Campain Interact", Close "Add Campain" form, then load userControl Campain_Interact into panel2 in Mainform.
This is pic form my work :
http://prntscr.com/mfpt8p[
^]
Can you guys help me ? And show me in detail with code, because I'm a baby in programing, and English is not my main language !
Thanks you
What I have tried:
This is in AddCampain.cs form. Even click generate by designer. But When I run this, it's said "Object Reference not set to an instance of an object" at this line :
pnl.panel2.Controls.Add(camPost);
pnl.panel2.Controls.Add(camInteract);
private void CampainPost_Click(object sender, EventArgs e) {
MainForm pnl = (MainForm)ParentForm;
Campain_Post camPost = new Campain_Post();
pnl.panel2.Controls.Add(camPost);
camPost.Dock = DockStyle.Fill;
camPost.BringToFront();
Close();
}
<pre> private void CampainInteraction_Click(object sender, EventArgs e) {
MainForm pnl = (MainForm)ParentForm;
Campain_Interaction camInteract = new Campain_Interaction ();
pnl.panel2.Controls.Add(camInteract);
camInteract .Dock = DockStyle.Fill;
camInteract .BringToFront();
Close();
}