Disable Docking option

6 posts, 1 answers
  1. Roy
    Roy avatar
    12 posts
    Member since:
    Sep 2013

    Posted 29 Sep 2013 Link to this post

    Hi,
    How should i disable the docking option in radDock control?

    example image attached.
  2. George
    Admin
    George avatar
    500 posts

    Posted 02 Oct 2013 Link to this post

    Hello Roy,

    Thank you for contacting us.

    You can disable the docking option in RadDock by canceling the corresponding transaction. You can subscribe to the TransactionCommitting event of the RadDock:
    this.radDock.TransactionCommitting += radDock_TransactionCommitting;

    Then in the event handler you can cancel the DragDrop and Float transaction types:
    void radDock_TransactionCommitting(object sender, RadDockTransactionCancelEventArgs e)
    {
        if (e.Transaction.TransactionType ==  DockTransactionType.DragDrop || e.Transaction.TransactionType ==  DockTransactionType.Float)
        {
            e.Cancel = true;
        }
    }

    I hope this information is helpful.
     
    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 >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Roy
    Roy avatar
    12 posts
    Member since:
    Sep 2013

    Posted 02 Oct 2013 Link to this post

    Thanks,
    its working great,  but i was wondering if there any option to disable even the arrows of dock when you're trying to drag the tab.
    ( exactly as in image )

    Best regards,
    Roy
  5. Answer
    George
    Admin
    George avatar
    500 posts

    Posted 07 Oct 2013 Link to this post

    Hi Roy,

    Thank you for writing back.

    In this case you would have to create a custom DragDropService. Below you can find the implementation of the class:
    public class MyDragDropService : DragDropService
    {
        public bool ShouldShowGuides { get; set; }
     
        protected override void Drag(Point mousePos)
        {
            if (this.ShouldShowGuides)
            {
                base.Drag(mousePos);
            }
            else
            {
                this.DragWithoutDockHint(mousePos);
                this.GetMethod("HideGuides").Invoke(this, null);
            }
        }
     
        protected virtual void DragWithoutDockHint(Point mousePos)
        {
            if (this.DragDropBehavior == DragDropBehavior.Auto && NativeMethods.GetCapture() == null)
            {
                this.Stop(false);
                return;
            }
     
            FieldInfo currMouse = this.GetField("currMouse");
            currMouse.SetValue(this, mousePos);
            FieldInfo prevMouse = this.GetField("prevMouse");
     
            if (this.DragDropBehavior == DragDropBehavior.Auto && ((Point)currMouse.GetValue(this)) == ((Point)prevMouse.GetValue(this)))
            {
                return;
            }
     
            prevMouse.SetValue(this, currMouse.GetValue(this));
            FieldInfo draggedWindow = this.GetField("draggedWindow");
     
            if (draggedWindow.GetValue(this) != null)
            {
                ((FloatingWindow)draggedWindow.GetValue(this)).BringToFront();
            }
     
            FieldInfo dropAnchor = this.GetField("dropAnchor");
            SplitPanel dropTarget = this.GetDropTarget();
            dropAnchor.SetValue(this, dropTarget);
     
            FieldInfo dragContext = this.GetField("dragContext");
     
            if (((DragDropContext)dragContext.GetValue(this)) == DragDropContext.DocumentWindow)
            {
                this.GetMethod("UpdateDocumentCursor").Invoke(this, null);
            }
     
            FieldInfo guideHitTest = this.GetField("guideHitTest");
     
            //we are not above a docking guide, move the dragged object
            if (((DockingGuideHitTest)guideHitTest.GetValue(this)) == DockingGuideHitTest.Empty)
            {
                this.GetMethod("MoveDraggedObject").Invoke(this, null);
            }
     
            //raise the Dragging event and check whether we may continue the operation.
            CancelEventArgs args = new CancelEventArgs();
            this.OnDragging(args);
            if (args.Cancel)
            {
                this.Stop(false);
            }
        }
     
        private FieldInfo GetField(string field)
        {
            return this.GetType().BaseType.GetField(field, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
        }
     
        private MethodInfo GetMethod(string method)
        {
            return this.GetType().BaseType.GetMethod(method, BindingFlags.Instance | BindingFlags.NonPublic);
        }
    }

    The service can be registered as follows:
    this.radDock.RegisterService(1, new MyDragDropService());

    Let me know if I can be of further assistance.

    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 >>
  6. Roy
    Roy avatar
    12 posts
    Member since:
    Sep 2013

    Posted 07 Oct 2013 Link to this post

    Thank you!   its works like a magic.
  7. George
    Admin
    George avatar
    500 posts

    Posted 07 Oct 2013 Link to this post

    Hi Roy,

    I am writing you again to let you know that we consider this as a reasonable feature request. That is why I created a new item in our Public Issue Tracking System. You can find it at http://www.telerik.com/support/pits.aspx#/public/winforms/15890.

    I have also updated your Telerik Points for the contribution.

    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 >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready