Prevent rearranging tabs / closing document windows in a DocumentContainer control.

5 posts, 0 answers
  1. Grant
    Grant avatar
    7 posts
    Member since:
    Oct 2009

    Posted 26 Dec 2011 Link to this post

    I added a DocumentContainer control with multiple DocumentWindows at design time, and I'd like to prevent closing or reordering the document windows.

    So far, I set the DocumentButtons property to None, and I found a post on here to disable the right-click context menu.

    However, in testing, users could still click the tab with their third mouse button / clickable scroll wheel and close a document window; I need to prevent this. Also, how do I prevent users from dragging tabs around to rearrange their order? I'd like to keep them in the order I chose at design time.

    Thanks to anyone with an answer!

  2. Grant
    Grant avatar
    7 posts
    Member since:
    Oct 2009

    Posted 28 Dec 2011 Link to this post

    Anyone know how to disable closing / reordering tabs in a DocumentContainer control, inside a RadDock?

  3. Stefan
    Admin
    Stefan avatar
    2439 posts
    Member since:
    Sep 2012

    Posted 29 Dec 2011 Link to this post

    Hi Grant,

    Thank you for writing.

    I am getting straight to your questions:
    1. How to prevent users from closing DocumentWindow.
    You can do that by subscribing to the DockWindowClosing event of RadDock and cancel the operation if the window that is being close is of type DocumentWindow:

    void radDock1_DockWindowClosing(object sender, Telerik.WinControls.UI.Docking.DockWindowCancelEventArgs e)
    {
        if (e.NewWindow is DocumentWindow)
        {
            e.Cancel = true;
        }
    }

    2. Is there a way to prevent users from dragging tabs around to rearrange their order? 
    Yes there is. To prevent the different docking operations, simply stop the DragDropService and to prevent the items from being rearranged set the ItemDragMode of the TabStripElement to None:
    DragDropService service = this.radDock1.GetService<DragDropService>();
    service.Enabled = false;

    documentTabStrip1.TabStripElement.ItemDragMode = Telerik.WinControls.UI.PageViewItemDragMode.None;

    I hope that the provided information addresses your questions. Should you have any other questions, do not hesitate to contact us.
     
    All the best,
    Stefan
    the Telerik teamQ3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

  4. Grant
    Grant avatar
    7 posts
    Member since:
    Oct 2009

    Posted 29 Dec 2011 Link to this post

    You're solutions were exactly what I needed. Thanks for the great support Stefan!  

  5. Stefan
    Admin
    Stefan avatar
    2439 posts
    Member since:
    Sep 2012

    Posted 30 Dec 2011 Link to this post

    Hello Grant,

    I am glad that I could help. If there is anything else we can assist you with, do not hesitate to contact us.
     
    All the best,
    Stefan
    the Telerik teamSP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

Back to Top