public void AddDocument(Control e, String title) { if (e != null) { foreach (var baseDocument in tabbedView1.Documents) { var doc = (Document)baseDocument; if (doc.Caption == title) { tabbedView1.Controller.Select(doc); return; } } DevExpress.XtraBars.Docking2010.Views.Tabbed.Document docs = tabbedView1.AddDocument(e) as DevExpress.XtraBars.Docking2010.Views.Tabbed.Document; docs.Caption = title; tabbedView1.Controller.Select(docs); } }
public static void CreateViews(IContainer components, DockManager dockManager, TabbedView tabbedView) { if (views != null && views.Count > 0) { DevExpress.XtraBars.Docking2010.Views.Tabbed.DocumentGroup documentGroup = new DevExpress.XtraBars.Docking2010.Views.Tabbed.DocumentGroup(components); tabbedView.DocumentGroups.AddRange(new DevExpress.XtraBars.Docking2010.Views.Tabbed.DocumentGroup[] { documentGroup }); for (int i = 0; i < views.Count; i++) { XtraUserControl uc = (XtraUserControl)views[i]; DockPanel dockPanel = new DevExpress.XtraBars.Docking.DockPanel(); DevExpress.XtraBars.Docking2010.Views.Tabbed.Document dockPanel_Document = new DevExpress.XtraBars.Docking2010.Views.Tabbed.Document(components); ControlContainer dockPanel_Container = new ControlContainer(); dockManager.RootPanels.AddRange(new DevExpress.XtraBars.Docking.DockPanel[] { dockPanel }); tabbedView.Documents.Add(dockPanel_Document); documentGroup.Items.Add(dockPanel_Document); dockPanel.Controls.Add(dockPanel_Container); dockPanel.DockedAsTabbedDocument = true; dockPanel.Options.AllowDockAsTabbedDocument = true; dockPanel.Options.AllowDockLeft = false; dockPanel.Options.AllowDockRight = false; dockPanel.Options.AllowDockTop = false; dockPanel.Options.AllowDockBottom = false; dockPanel.Options.AllowDockFill = false; dockPanel.ID = System.Guid.NewGuid(); string strName = DateTime.Now.Ticks.ToString(); dockPanel.Name = "dockPanel" + strName; dockPanel.OriginalSize = new System.Drawing.Size(300, 300); dockPanel.Text = views[i].Title; dockPanel.SavedIndex = i; dockPanel.SavedMdiDocument = true; dockPanel.FloatLocation = new System.Drawing.Point(0, 0); if (views[i].ShowCloseButton) { dockPanel.Options.ShowCloseButton = true; } else { dockPanel.Options.ShowCloseButton = false; } dockPanel_Container.Controls.Add(uc); dockPanel_Container.Location = new System.Drawing.Point(0, 0); dockPanel_Container.Name = "dockPanel_Container" + strName; dockPanel_Container.Size = new System.Drawing.Size(300, 300); dockPanel_Container.TabIndex = 0; uc.Dock = System.Windows.Forms.DockStyle.Fill; uc.Location = new System.Drawing.Point(0, 0); uc.Name = "uc" + strName; uc.Size = new System.Drawing.Size(300, 300); uc.TabIndex = 0; dockPanel_Document.Caption = views[i].Title; dockPanel_Document.ControlName = dockPanel.Name; dockPanel_Document.FloatLocation = new System.Drawing.Point(0, 0); dockPanel_Document.FloatSize = new System.Drawing.Size(300, 300); if (views[i].ShowCloseButton) { dockPanel_Document.Properties.AllowClose = DevExpress.Utils.DefaultBoolean.True; } else { dockPanel_Document.Properties.AllowClose = DevExpress.Utils.DefaultBoolean.False; } if (views[i].IsActive) { InitActivateViewText = views[i].Title; } ContentCollection.Add(views[i]); } } }