private void CreateDockBar(DockSite parentSite) { IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost; if (dh == null) return; IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService; DotNetBarManager dm = this.Component as DotNetBarManager; DesignerTransaction dt = dh.CreateTransaction("Creating Dock Bar"); try { // Make sure that DockSite has document manager if (parentSite.DocumentDockContainer == null) TypeDescriptor.GetProperties(parentSite)["DocumentDockContainer"].SetValue(parentSite, new DocumentDockContainer()); Bar bar = dh.CreateComponent(typeof(Bar)) as Bar; bar.AutoSyncBarCaption = true; bar.CloseSingleTab = true; bar.CanDockDocument = false; bar.Style = dm.Style; bar.LayoutType = eLayoutType.DockContainer; bar.GrabHandleStyle = eGrabHandleStyle.Caption; bar.Stretch = true; // Add Dock Container to it... DockContainerItem dockItem = dh.CreateComponent(typeof(DockContainerItem)) as DockContainerItem; dockItem.Text = dockItem.Name; bar.Items.Add(dockItem); // Panel for DockContainerItem PanelDockContainer panel = dh.CreateComponent(typeof(PanelDockContainer)) as PanelDockContainer; bar.Controls.Add(panel); panel.ColorSchemeStyle = bar.Style; panel.ApplyLabelStyle(); dockItem.Control = panel; bar.SelectedDockTab = 0; // Add them to the dock manager cc.OnComponentChanging(parentSite, null); parentSite.GetDocumentUIManager().Dock(bar); parentSite.RecalcLayout(); cc.OnComponentChanged(parentSite, null, null, null); } catch { dt.Cancel(); } finally { if (!dt.Canceled) dt.Commit(); } }