This is a migrated thread and some comments may be shown as answers.

Preserving order of Tabbed Document

2 Answers 79 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Edward
Top achievements
Rank 1
Edward asked on 31 Jan 2008, 08:37 PM
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 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 01 Feb 2008, 02:22 PM
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
0
Edward
Top achievements
Rank 1
answered on 04 Feb 2008, 03:56 PM
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; 
        }  

Tags
Dock
Asked by
Edward
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Edward
Top achievements
Rank 1
Share this question
or