I create 2 menus (one for admin and another for user) those two menus are user controls, and I have a panel which will shows all content (Other user control) ..
userControl 1 is : Admin_menu
Button1 : button in Admin_menu
Button2 : button in Admin_menu
userControl 3 is : content1
userControl 4 is : content2
I have a main form that contains two sides : left side : Admin_menu right side : panel where the content will shows up
All the userControls are added to main form
the problem is : when I click on a button1 for showing content1, or button2 for showing content2 , I get this message :
My code in Admin_menu.cs :
public Admin_menu()
{
InitializeComponent();
}
private void btnTrainers_Click(object sender, EventArgs e)
{
Parent.Controls["trainersTab1"].BringToFront();
}
private void btnBranches_Click(object sender, EventArgs e)
{
//BranchesTab branchespage = new BranchesTab();
//this.Parent.Controls.Add(branchespage);
Parent.Controls["branchespage"].BringToFront();
}
private void btnTimeTables_Click(object sender, EventArgs e)
{
Parent.Controls["timeTableTab1"].BringToFront();
}
trainersTab1
,branchespage
are added toAdmin_Menu
as part ofInitializeComponent
code? Are they added directly to theAdmin_Menu
or they are part of some container control such as Group Box or Panel inAdmin_Menu
? Are you using correct names of the controls to find them? – Chetan