I have a strange situation. I am adding bunch of Controls in Ultradockmanager at run time by adding dockable pane, dockablegroup pane etc.
After that I am calling RepositionToPane method to reposition one of the panes. Now if I again add a control at run time it does not shows up as a pane. But if I comment the code for repositioning the pane then addition of the controls works fine.
I am attaching a sample project which has the issue.
First run the project and Click on "Add Control" button you will see the controls getting added
Then just go inside the code and un comment the line( RepositionControl("Control0", 1);)
in public Form1() to see that now no control will be added if you hit "Add Control" button.Can some one let me know what is wrong in the code? Or is it a bug in Ultradockmanager. Please help
Hello,
Whenever panes are repositioned (both programmatically and via dragdrop), the UltraDockManager flattens/minimizes the pane hierarchy by removing any unnecessary panes. In this case, the DockableGroupPane (tabGroup) and the DockAreaPane have the same ChildPaneStyle, so the child panes were reparented to the DockArea, and the tabGroup pane was removed.
In your sample, a reference to the tabGroup is being maintained as a member of the form. When a new DockableControlPane is being added (after the RepositionControl() call), it is being add to the tabGroup pane which is no longer being utilized by the UltraDockManager. While debugging, you will see the Parent property of the tabGroup is null after the RepositionToPane() call.
In situations where you want to programmatically add another pane to an existing location, you should "find" the DockableGroupPane each time instead of maintaining a reference to one. Try using the following code to find the TabGroup instead of maintaining a reference.
private DockableGroupPane FindTabGroup()
{
// find the dock area
DockAreaPane dockArea = null;
foreach (DockAreaPane dap in this.ultraDockManager1.DockAreas)
if (dap.DockedLocation == DockedLocation.DockedLeft)
dockArea = dap;
break;
}
if (dockArea == null)
// create a new dockarea
dockArea = new DockAreaPane(DockedLocation.DockedLeft);
dockArea.ChildPaneStyle = ChildPaneStyle.TabGroup;
this.ultraDockManager1.DockAreas.Add(dockArea);
if (dockArea.ChildPaneStyle == ChildPaneStyle.TabGroup)
return dockArea;
// look for a TabGroup child pane
foreach (DockablePaneBase childPane in dockArea.Panes)
DockableGroupPane dpg = childPane as DockableGroupPane;
if (dpg != null && dpg.ChildPaneStyle == ChildPaneStyle.TabGroup)
return dpg;
this.tabGroup = new DockableGroupPane();
this.tabGroup.ChildPaneStyle = ChildPaneStyle.TabGroup;
dockArea.Panes.Add(tabGroup);
return tabGroup;
You might be able to utilize the tabGroup member reference in the FindTabGroup() method by adding a tabGroup.Parent != null check.
if (this.tabGroup != null && this.tabGroup.Parent != null)
Let me know if you require any further assistance.
Thanks,
Chris
Thanks for the clarification Chris. Your solution works perfect !!!!