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

How to lock a document as the first in a tab strip

1 Answer 81 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Rock
Top achievements
Rank 1
Rock asked on 23 Sep 2013, 09:25 PM
I'd like to have my documents tab strip always show the same document in the first tab, but let the other tabbed documents be rearranged. I've got the close button functionality working (the first document cannot be closed, the others can), but I can't seem to get the drag/drop constraints working. I have made it so the first document cannot be dragged (by setting TabStripItem.AllowDrag), but it's still possible to drag a different document in front of the one I want locked as the first document. 

In approaching this problem, I haven't been able to find an event I could cancel to achieve the effect. Another approach might be to rearrange the tabs if I notice they've changed (e.g. when the ActiveWindowChanged event fires), but its not obvious how to rearrange the tabs programmatically. 

Any pointers?

1 Answer, 1 is accepted

Sort by
0
George
Telerik team
answered on 26 Sep 2013, 01:58 PM
Hello Rock,

Thank you for writing.

In order to manage Drag-Drop operations between DocumentWindows in RadDock you need to access their RadPageViewElements and subscribe for the ItemDropping event:
private RadDock radDock1 = new RadDock();
 
public Form1()
{
    InitializeComponent();
 
    this.Controls.Add(this.radDock1);
    this.radDock1.Dock = DockStyle.Fill;
     
    for (int i = 0; i < 3; i++)
    {
        this.radDock1.AddDocument(new DocumentWindow() { Name = i.ToString() });
    }
 
    this.Load += Form1_Load;
}
 
private void Form1_Load(object sender, EventArgs e)
{
    foreach (Control child in ControlHelper.EnumChildControls(this.radDock1,true))
    {
        DocumentTabStrip docStrip = child as DocumentTabStrip;
        if (docStrip != null)
        {
            RadPageViewElement pageViewElement = docStrip.TabStripElement;
            pageViewElement.ItemDropping += PageViewElement_ItemDropping;
        }
    }
}
 
private void PageViewElement_ItemDropping(object sender, RadPageViewItemDroppingEventArgs e)
{
    if (e.TargetItem.Text == "2")
    {
        e.Cancel = true;
    }
}

I hope this helps.
 
Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Dock
Asked by
Rock
Top achievements
Rank 1
Answers by
George
Telerik team
Share this question
or