Tearing off the DockContainerItem from the Bar control involves following steps:

  1. Remove DockContainerItem from its current Bar
  2. Create new Bar to host the DockContainerItem
  3. Add DockContainerItem to the newly created Bar control
  4. Add Bar control to the DotNetBarManager
  5. Float or Dock the Bar
// Remove DockContainerItem from its current parent
 
Bar previousParent = dockContainerItem1.ContainerControl as Bar;
 
previousParent.Items.Remove(dockContainerItem1);
 
// Create new Bar to hold the DockContainerItem that is torn off
 
Bar bar = new Bar(dockContainerItem1.Text);
 
bar.LayoutType = eLayoutType.DockContainer;
bar.GrabHandleStyle = eGrabHandleStyle.Caption;
bar.Stretch = true;
bar.Name = "float" + dockContainerItem1.Name;
 
// Add it to DotNetBarManager
 
dotNetBarManager1.Bars.Add(bar);
 
// Add DockContainerItem to the newly created bar
 
bar.Items.Add(dockContainerItem1);
 
// Specify inital floating location
 
bar.InitalFloatLocation = new Point(100, 100);
 
// If not already set, specify default floating size
 
dockContainerItem1.DefaultFloatingSize = new Size(200, 300);
 
// Float the bar
 
bar.DockSide = eDockSide.None;
' Remove DockContainerItem from its current parent

previousParent.Items.Remove(DockContainerItem1)
 
' Create new Bar to hold the DockContainerItem that is torn off

Dim bar As Bar = New Bar(DockContainerItem1.Text)
 
bar.LayoutType = eLayoutType.DockContainer
bar.GrabHandleStyle = eGrabHandleStyle.Caption
bar.Stretch = True
bar.Name = "float" + DockContainerItem1.Name
 
' Add it to DotNetBarManager

DotNetBarManager1.Bars.Add(bar)
 
' Add DockContainerItem to the newly created bar

bar.Items.Add(DockContainerItem1)
 
' Specify inital floating location

bar.InitalFloatLocation = New Point(100, 100)
 
' If not already set, specify default floating size

DockContainerItem1.DefaultFloatingSize = New Size(200, 300)
 
' Float the bar

bar.DockSide = eDockSide.None

The following samples can be downloaded to show this in action.
DockContainerItemTearOffCS
DockContainerItemTearOffVB

Related posts:

  1. Changing DockContainerItem.Visible
  2. Working with DotNetBar from code.
  3. How to create Dockable Windows
  4. How to Create Menu Using Code
  5. How to Create/Remove Tabs Using Code