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

2 posts, 0 answers
  1. Rock
    Rock avatar
    4 posts
    Member since:
    Sep 2013

    Posted 23 Sep 2013 Link to this post

    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?
  2. George
    George avatar
    500 posts

    Posted 26 Sep 2013 Link to this post

    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()
        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.
    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 >>
Back to Top