点击菜单导航栏 弹出的窗体显示到TBACONTORL中

上不了图:直接上源码

private void treeview_hr_AfterSelect(object sender, TreeViewEventArgs e)
{
TreeNode node = e.Node;
if (node.Level == 1) //子节点
{

if (!this.tab_main.TabPages.ContainsKey(node.Text.Trim()))
{
HR.ModuleClass.MyModule mymodule = new HR.ModuleClass.MyModule();

if (mymodule.Get_Form(node.Text.Trim())!=null)
{

this.tab_main.TabPages.Add(mymodule.Get_Form(node.Text.Trim()));
this.tab_main.SelectedIndex = this.tab_main.TabPages.Count - 1;
}
}
else
{
this.tab_main.SelectedTab = this.tab_main.TabPages[node.Text.Trim()];
}

}

}

public TabPage Get_Form(string FrmName)
{
if (FrmName == "用户管理")
{
HR.SystemManage.frm_usermgr frm = new HR.SystemManage.frm_usermgr();
frm.Text = "用户管理";
frm.TopLevel = false;
TabPage tp = new TabPage(frm.Text);
tp.Name = frm.Text;
tp.Controls.Add(frm);
frm.Dock = DockStyle.Fill;
frm.Show();
return tp;

}
else if (FrmName == "采购单")
{
HR.SystemManage.frm_purchase frm = new HR.SystemManage.frm_purchase();
frm.Text = "采购单";
frm.TopLevel = false;
TabPage tp = new TabPage(frm.Text);
tp.Name = frm.Text;
tp.Controls.Add(frm);
frm.Dock = DockStyle.Fill;
frm.Show();
return tp;

}
else
{
return null;
}

}

你可能感兴趣的:(菜单)