DevExpress XtraTabControl 加载Form

  • A+
所属分类:C#

DevExpress XtraTabControl 加载Form - 在 水 一 方 - 博客园

DevExpress XtraTabControl 加载Form

Devexpress 控件使用
 1     public partial class Form1 : XtraForm
 2     {
 3         public Form1()
 4         {
 5             InitializeComponent();
 6
 7             XtraTabPage page = new XtraTabPage();
 8             XtraForm1 from1 = new XtraForm1
 9                                   {
10                                       Visible = true,
11                                       Dock = DockStyle.Fill,

12                                       FormBorderStyle = FormBorderStyle.None,

13                                       TopLevel = false//在这里一定要注意  不然加载不出来

14                                   };
15             page.Controls.Add(from1);
16             page.Text = from1.Text;
17             xtraTabControl1.TabPages.Add(page);
18
19
//设置关闭事件

xtraTabControl1.CloseButtonClick += new EventHandler(XtraTabControl1CloseButtonClick);

20         }
21
        //在程序关闭之后 要释放窗体等资源

22         void XtraTabControl1CloseButtonClick(object sender, EventArgs e)
23         {
24             ClosePageButtonEventArgs a = (ClosePageButtonEventArgs)e;
25             string tabpagename = a.Page.Text;
26             foreach (Control xtp in xtraTabControl1.TabPages)
27             {
28                     if (xtp.Text == tabpagename)
29                     {
30                         xtp.Dispose();
31                         return;
32                     }
33             }
34         }
35     }

void xtraTabControl1_CloseButtonClick(object sender, EventArgs e)
        {

DevExpress.XtraTab.ViewInfo.ClosePageButtonEventArgs a = (DevExpress.XtraTab.ViewInfo.ClosePageButtonEventArgs)e;

string tabpagename = a.Page.Text;
            foreach (XtraTabPage xtp in xtraTabControl1.TabPages)
            {

//if (xtp.ShowCloseButton.Equals(DevExpress.Utils.DefaultBoolean.True))

//{
                    if (xtp.Text == tabpagename)
                    {

DevExpress.XtraEditors.XtraForm form = xtp.Controls[0] as DevExpress.XtraEditors.XtraForm;

form.Close();
                        form.Dispose();

xtraTabControl1.TabPages.Remove((a.Page as XtraTabPage));

xtp.Dispose();
                        return;
                    }
                //}
            }
        }

DevComponents.DotNetBar 控件添加选项卡  同理

OfficeForm form1 = new Form1();
                SuperTabItem tabItem = superTabControl1.CreateTab("基本信息");
                tabItem.Name = "myNIn";
                tabItem.Text = "基本信息";
                form1.TopLevel = false;
                form1.FormBorderStyle = FormBorderStyle.None;
                form1.Dock = DockStyle.Fill;
                form1.Visible = true;
                tabItem.AttachedControl.Controls.Add(form1);
                superTabControl1.SelectedTab = tabItem;

  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin