Adding Scrollbar to NDockManger.RootContainer


https://www.nevron.com/Forum/Topic8965.aspx
Print Topic | Close Window

By Jarrett Robertson - 9 Years Ago

Hi,

I have a requirement in which i have to add about 50-55 Panels in DockManager.RootContainer.
So I wrote code like this:

NDockManager mDockManager;
public PlotControl()
{
   mDockManager = new NDockManager();
   mDockManager.RootContainer.RootZone.Orientation = Orientation.Vertical;
   mDockManager.RootContainer.AutoScroll = true;
   mDockManager.UndockToleranceSize = 2;
   mDockManager.DisposePanelsOnClose = true;

   Form lForm = new Form();
   lForm.Dock = DockStyle.Fill;
   lForm.TopLevel = false;
   lForm.FormBorderStyle = FormBorderStyle.None;
   mDockManager.Form = lForm;
   lForm.Show();
   mSplitContainer.Panel2.Controls.Add(lForm);
}

private void AddStrip()
{
   NDockingPanelHost lPanelHost = new NDockingPanelHost();
   NDockingPanel lPanel = new NDockingPanel();
   lPanel.Dock = System.Windows.Forms.DockStyle.Fill;
   lPanelHost.AddChild(lPanel);
   int lPanelIndex = mDockManager.RootContainer.RootZone.Children.Count - 1;
   mDockManager.RootContainer.RootZone.AddChild(lPanelHost, lPanelIndex);
  ResizeDockManager();
}

private void RemoveStrip()
{
   lPanelHost.RemoveChild(lPanel);
   mDockManager.RootContainer.RootZone.RemoveChild(lPanelHost);
   ResizeDockManager();
}

private void ResizeDockManager()
{
   int lHeight = 0;
   mDockManager.RootContainer.Size = new Size(mDockManager.DockSurface.Size.Width, lHeight);
   foreach(INDockZoneChild lChild in mDockManager.RootContainer.RootZone.Children)
   {
       if(lChild is NDockingPanelHost)      
             lHeight += lChild.Bounds.Height;      
       mDockManager.RootContainer.Size = new Size(mDockManager.DockSurface.Size.Width, lHeight + 50);
   }
}

ResizeDockManager() method is calling in two cases while adding and removing panel.

The above code is increasing the height of the mDockManager.DockSurface height while adding Panels by setting mDockManager.RootContainer.Size, but when I remove the Panel from container Height of the DockSurface is not updating and mDockManager.Panels.Length is not updating.
How do i achieve this?