Loop through all dockpanels

2 posts, 0 answers
  1. kortm
    kortm avatar
    6 posts
    Member since:
    Feb 2007

    Posted 30 Mar 2007 Link to this post

      Hello,
    I want to loop through all the dock panels that are in the docking manager in order to remove the hidden panel.
    I try to use the PrimarySite Property:  
    foreach (IDockable document1 in (dockingManager1.PrimarySite as DockSite).Documents)
    {
    if (document1.DockState == DockState.Hidden)
    {dockingManager1.Remove(document1);}
    }
    I can't seem to get that to work.  Any help would be appreciated.

    in other words, how can I get a panel from the dockmanager ?
    Thanks,
    KORT
  2. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 30 Mar 2007 Link to this post

    Hello Kort,

    Your code is correct, but it is valid only for DockPanels and any IDockable windows which inherit from DockType.ToolWindow. When you close a window of type DockType.Document (e.g. DocumentPane) it is automatically removed from the docking manager.

    If you would like to go through all the other windows you should do the following:
    foreach (IDockable window in dockingManager1.GetManagedDockables())  
    {  
        if (window.DockState != DockState.Docked || window.DockState != DockState.TabbedDocument || window.DockState != DockState.AutoHide)  
        {  
            //unregister window from docking manager  
            dockingManager1.Remove(window);  
     
            //dispose the window  
            Control ctrl = window as Control;  
            if (ctrl != null)  
            {  
                ctrl.Dispose();  
            }  
        }  

    All the best,
    Julian Benkov
    the telerik team

    Instantly find answers to your questions at the new telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top