Preserving order of Tabbed Document

3 posts, 0 answers
  1. Edward
    Edward  avatar
    32 posts
    Member since:
    Jan 2008

    Posted 31 Jan 2008 Link to this post

    Say I have the following in a tabbed document A B C D E.  If I move C out of the group, then dock it back in, it will show up as A B D E C instead.  I guess that's what I need:

    1) An event that detects tabbed document movement
    2) A method or property that change the order
  2. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 01 Feb 2008 Link to this post

    Hi Edward ,

    You can use following code snippet:

    private void dockingManager1_DockingStateChanged(object sender, DockingChangedEventArgs e)  
    {  
        if (e.DockObject.DockState == DockState.TabbedDocument)  
        {  
            if (e.DockObject == documentPane3)  
            {  
                SetTabPosition(documentPane3, 2);  
            }  
        }  
    }  
     
    private void radButton1_Click(object sender, EventArgs e)  
    {  
        dockingManager1.RemoveDocument(documentPane3);  
    }  
     
    private void radButton2_Click(object sender, EventArgs e)  
    {  
        dockingManager1.SetDocument(documentPane3);  
    }  
     
    private bool SetTabPosition(IDockable window, int index)  
    {  
        RadTabStripElement tabStrip = ((DocumentPresenterControl)documentPane3.DefaultPresenter).DocumentPresenterElement.TabStripElement;  
     
        for (int i = 0; i < tabStrip.Items.Count; i++)  
        {  
            if (((DockableTab)tabStrip.Items[i]).Element == window)  
            {  
                RadItem item = tabStrip.Items[i];  
                tabStrip.Items.RemoveAt(i);  
     
                if (index < tabStrip.Items.Count)  
                {  
                    tabStrip.Items.Insert(index, item);  
                    return true;  
                }  
            }  
        }  
     
        return false;  


    Kind regards,
    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
  4. Edward
    Edward  avatar
    32 posts
    Member since:
    Jan 2008

    Posted 04 Feb 2008 Link to this post

    I made a small modification and it works perfectly.

            private bool SetTabPosition(IDockable window, int index) 
            { 
                RadTabStripElement tabStrip = ((DocumentPresenterControl)window.DefaultPresenter).DocumentPresenterElement.TabStripElement; 
                Telerik.WinControls.RadItem item = null
     
                for (int i = 0; i < tabStrip.Items.Count; i++) 
                { 
                    if (((DockableTab)tabStrip.Items[i]).Element == window) 
                    { 
                        item = tabStrip.Items[i]; 
                        tabStrip.Items.RemoveAt(i); 
     
                        if (index <= tabStrip.Items.Count) 
                        { 
                            tabStrip.Items.Insert(index, item); 
                            return true; 
                        } 
                    } 
                } 
                tabStrip.Items.Insert(tabStrip.Items.Count, item); 
     
                return false; 
            }  

Back to Top