xtraTabControl1
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xtraTabControl1相关的知识,希望对你有一定的参考价值。
using DevExpress.XtraTab; using System; using System.Windows.Forms; namespace FrmMain { using DevExpress.XtraBars.Helpers; public partial class FrmMain : DevExpress.XtraBars.Ribbon.RibbonForm { public FrmMain() { InitializeComponent(); } private void xtraTabControl1_CloseButtonClick(object sender, EventArgs e) { DevExpress.XtraTab.ViewInfo.ClosePageButtonEventArgs eArg = (DevExpress.XtraTab.ViewInfo.ClosePageButtonEventArgs)e; string name = eArg.Page.Text;//得到关闭的选项卡的text foreach (XtraTabPage page in xtraTabControl1.TabPages)//遍历得到和关闭的选项卡一样的Text { if (page.Text == name) { xtraTabControl1.TabPages.Remove(page); page.Dispose(); return; } } } private void itemRuKuXinXi_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e) { string name = e.Link.Caption; //判断是否已创建过 foreach (XtraTabPage page in xtraTabControl1.TabPages) { if (page.Text == name) { xtraTabControl1.SelectedTabPage = page;//显示该页 return; } } //增加tabpage XtraTabPage xpage = new XtraTabPage(); xpage.Name = name; xpage.Text = name; //向xtraTabControl1中添加窗体 FrmRuKuXinXi frm = new FrmRuKuXinXi(); frm.Visible = true; frm.Dock = DockStyle.Fill; frm.FormBorderStyle = FormBorderStyle.None; frm.TopLevel = false;//在这里一定要注意 负责是加载不出来的 xpage.Controls.Add(frm);//添加要增加的控件 xtraTabControl1.TabPages.Add(xpage); xtraTabControl1.SelectedTabPage = xpage;//显示该页 } private void itemChuKuXinXi_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e) { string name = e.Link.Caption; //判断是否已创建过 foreach (XtraTabPage page in xtraTabControl1.TabPages) { if (page.Text == name) { xtraTabControl1.SelectedTabPage = page;//显示该页 return; } } //增加tabpage XtraTabPage xpage = new XtraTabPage(); xpage.Name = name; xpage.Text = name; //向xtraTabControl1中添加窗体 FrmChuKuXinXi frm = new FrmChuKuXinXi(); frm.Visible = true; frm.Dock = DockStyle.Fill; frm.FormBorderStyle = FormBorderStyle.None; frm.TopLevel = false;//在这里一定要注意 负责是加载不出来的 xpage.Controls.Add(frm);//添加要增加的控件 xtraTabControl1.TabPages.Add(xpage); xtraTabControl1.SelectedTabPage = xpage;//显示该页 } private void itemRuKuXinXiHuiZong_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e) { string name = e.Link.Caption; //判断是否已创建过 foreach (XtraTabPage page in xtraTabControl1.TabPages) { if (page.Text == name) { xtraTabControl1.SelectedTabPage = page;//显示该页 return; } } //增加tabpage XtraTabPage xpage = new XtraTabPage(); xpage.Name = name; xpage.Text = name; //向xtraTabControl1中添加窗体 FrmRuKuXinXiHuiZong frm = new FrmRuKuXinXiHuiZong(); frm.Visible = true; frm.Dock = DockStyle.Fill; frm.FormBorderStyle = FormBorderStyle.None; frm.TopLevel = false;//在这里一定要注意 负责是加载不出来的 xpage.Controls.Add(frm);//添加要增加的控件 xtraTabControl1.TabPages.Add(xpage); xtraTabControl1.SelectedTabPage = xpage;//显示该页 } private void itemShiLiaoJiChuXinXi_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e) { string name = e.Link.Caption; //判断是否已创建过 foreach (XtraTabPage page in xtraTabControl1.TabPages) { if (page.Text == name) { xtraTabControl1.SelectedTabPage = page;//显示该页 return; } } //增加tabpage XtraTabPage xpage = new XtraTabPage(); xpage.Name = name; xpage.Text = name; //向xtraTabControl1中添加窗体 FrmShiLiaoJiChuXinXi frm = new FrmShiLiaoJiChuXinXi(); frm.Visible = true; frm.Dock = DockStyle.Fill; frm.FormBorderStyle = FormBorderStyle.None; frm.TopLevel = false;//在这里一定要注意 负责是加载不出来的 xpage.Controls.Add(frm);//添加要增加的控件 xtraTabControl1.TabPages.Add(xpage); xtraTabControl1.SelectedTabPage = xpage;//显示该页 } private void itemCheLiangXinXiWeiHu_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e) { string name = e.Link.Caption; //判断是否已创建过 foreach (XtraTabPage page in xtraTabControl1.TabPages) { if (page.Text == name) { xtraTabControl1.SelectedTabPage = page;//显示该页 return; } } //增加tabpage XtraTabPage xpage = new XtraTabPage(); xpage.Name = name; xpage.Text = name; //向xtraTabControl1中添加窗体 FrmCheLiangXinXiWeiHu frm = new FrmCheLiangXinXiWeiHu(); frm.Visible = true; frm.Dock = DockStyle.Fill; frm.FormBorderStyle = FormBorderStyle.None; frm.TopLevel = false;//在这里一定要注意 负责是加载不出来的 xpage.Controls.Add(frm);//添加要增加的控件 xtraTabControl1.TabPages.Add(xpage); xtraTabControl1.SelectedTabPage = xpage;//显示该页 } private void itemFuKuanFangShiWeiHu_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e) { string name = e.Link.Caption; //判断是否已创建过 foreach (XtraTabPage page in xtraTabControl1.TabPages) { if (page.Text == name) { xtraTabControl1.SelectedTabPage = page;//显示该页 return; } } //增加tabpage XtraTabPage xpage = new XtraTabPage(); xpage.Name = name; xpage.Text = name; //向xtraTabControl1中添加窗体 FrmFuKuanFangShiWeiHu frm = new FrmFuKuanFangShiWeiHu(); frm.Visible = true; frm.Dock = DockStyle.Fill; frm.FormBorderStyle = FormBorderStyle.None; frm.TopLevel = false;//在这里一定要注意 负责是加载不出来的 xpage.Controls.Add(frm);//添加要增加的控件 xtraTabControl1.TabPages.Add(xpage); xtraTabControl1.SelectedTabPage = xpage;//显示该页 } private void itemKeHuXinXiWeiHu_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e) { string name = e.Link.Caption; //判断是否已创建过 foreach (XtraTabPage page in xtraTabControl1.TabPages) { if (page.Text == name) { xtraTabControl1.SelectedTabPage = page;//显示该页 return; } } //增加tabpage XtraTabPage xpage = new XtraTabPage(); xpage.Name = name; xpage.Text = name; //向xtraTabControl1中添加窗体 FrmKeHuXinXiWeiHu frm = new FrmKeHuXinXiWeiHu(); frm.Visible = true; frm.Dock = DockStyle.Fill; frm.FormBorderStyle = FormBorderStyle.None; frm.TopLevel = false;//在这里一定要注意 负责是加载不出来的 xpage.Controls.Add(frm);//添加要增加的控件 xtraTabControl1.TabPages.Add(xpage); xtraTabControl1.SelectedTabPage = xpage;//显示该页 } private void itemYuanLiaoDiWeiHu_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e) { string name = e.Link.Caption; //判断是否已创建过 foreach (XtraTabPage page in xtraTabControl1.TabPages) { if (page.Text == name) { xtraTabControl1.SelectedTabPage = page;//显示该页 return; } } //增加tabpage XtraTabPage xpage = new XtraTabPage(); xpage.Name = name; xpage.Text = name; //向xtraTabControl1中添加窗体 FrmYuanLiaoDiWeiHu frm = new FrmYuanLiaoDiWeiHu(); frm.Visible = true; frm.Dock = DockStyle.Fill; frm.FormBorderStyle = FormBorderStyle.None; frm.TopLevel = false;//在这里一定要注意 负责是加载不出来的 xpage.Controls.Add(frm);//添加要增加的控件 xtraTabControl1.TabPages.Add(xpage); xtraTabControl1.SelectedTabPage = xpage;//显示该页 } private void itemRenYuanXinXiWeiHu_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e) { string name = e.Link.Caption; //判断是否已创建过 foreach (XtraTabPage page in xtraTabControl1.TabPages) { if (page.Text == name) { xtraTabControl1.SelectedTabPage = page;//显示该页 return; } } //增加tabpage XtraTabPage xpage = new XtraTabPage(); xpage.Name = name; xpage.Text = name; //向xtraTabControl1中添加窗体 FrmRenYuanXinXiWeiHu frm = new FrmRenYuanXinXiWeiHu(); frm.Visible = true; frm.Dock = DockStyle.Fill; frm.FormBorderStyle = FormBorderStyle.None; frm.TopLevel = false;//在这里一定要注意 负责是加载不出来的 xpage.Controls.Add(frm);//添加要增加的控件 xtraTabControl1.TabPages.Add(xpage); xtraTabControl1.SelectedTabPage = xpage;//显示该页 } private void itemYongHuGuanLi_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e) { string name = e.Link.Caption; //判断是否已创建过 foreach (XtraTabPage page in xtraTabControl1.TabPages) { if (page.Text == name) { xtraTabControl1.SelectedTabPage = page;//显示该页 return; } } //增加tabpage XtraTabPage xpage = new XtraTabPage(); xpage.Name = name; xpage.Text = name; //向xtraTabControl1中添加窗体 FrmYongHuGuanLi frm = new FrmYongHuGuanLi(); frm.Visible = true; frm.Dock = DockStyle.Fill; frm.FormBorderStyle = FormBorderStyle.None; frm.TopLevel = false;//在这里一定要注意 负责是加载不出来的 xpage.Controls.Add(frm);//添加要增加的控件 xtraTabControl1.TabPages.Add(xpage); xtraTabControl1.SelectedTabPage = xpage;//显示该页 } private void itemXiuGaiMiMa_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e) { string name = e.Link.Caption; //判断是否已创建过 foreach (XtraTabPage page in xtraTabControl1.TabPages) { if (page.Text == name) { xtraTabControl1.SelectedTabPage = page;//显示该页 return; } } //增加tabpage XtraTabPage xpage = new XtraTabPage(); xpage.Name = name; xpage.Text = name; //向xtraTabControl1中添加窗体 FrmXiuGaiMiMa frm = new FrmXiuGaiMiMa(); frm.Visible = true; frm.Dock = DockStyle.Fill; frm.FormBorderStyle = FormBorderStyle.None; frm.TopLevel = false;//在这里一定要注意 负责是加载不出来的 xpage.Controls.Add(frm);//添加要增加的控件 xtraTabControl1.TabPages.Add(xpage); xtraTabControl1.SelectedTabPage = xpage;//显示该页 } private void itemCanShuSheZhi_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e) { string name = e.Link.Caption; //判断是否已创建过 foreach (XtraTabPage page in xtraTabControl1.TabPages) { if (page.Text == name) { xtraTabControl1.SelectedTabPage = page;//显示该页 return; } } //增加tabpage XtraTabPage xpage = new XtraTabPage(); xpage.Name = name; xpage.Text = name; //向xtraTabControl1中添加窗体 FrmCanShuSheZhi frm = new FrmCanShuSheZhi(); frm.Visible = true; frm.Dock = DockStyle.Fill; frm.FormBorderStyle = FormBorderStyle.None; frm.TopLevel = false;//在这里一定要注意 负责是加载不出来的 xpage.Controls.Add(frm);//添加要增加的控件 xtraTabControl1.TabPages.Add(xpage); xtraTabControl1.SelectedTabPage = xpage;//显示该页 } private void FrmMain_Load(object sender, EventArgs e) { WindowState = FormWindowState.Maximized; //// 启动更换皮肤控件 //SkinHelper.InitSkinGallery(ribbonGalleryBarItem1); ////// 设置默认皮肤//DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("Office 2010 Blue"); } } }
以上是关于xtraTabControl1的主要内容,如果未能解决你的问题,请参考以下文章