We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to prevent dragging of a particular panel in the form of WinForms Docking Manager?

Platform: WinForms |
Control: DockingManager

Prevent dragging of a particular panel

To prevent dragging of a particular panel in the form the cancellable argument of the DragAllow event has to be set as True. Please refer the below code snippet which illustrates this:


private void dockingManager1_DragAllow(object sender, Syncfusion.Windows.Forms.Tools.DragAllowEventArgs arg)
   //If the control being dragged is Panel1, then cancel the drag.
   if(arg.Control == this.panel1)
      arg.Cancel = true;
      MessageBox.Show("Access denied to drag the window");
   //If a tab group containing the panel is dragged then, cancel the drag.
   Syncfusion.Windows.Forms.Tools.DockHost dhost = arg.Control.Parent as  Syncfusion.Windows.Forms.Tools.DockHost;
   Syncfusion.Windows.Forms.Tools.DockHostController dhc = dhost.InternalController as Syncfusion.Windows.Forms.Tools.DockHostController;
   if(dhc.ParentController is Syncfusion.Windows.Forms.Tools.DockTabController)
     Syncfusion.Windows.Forms.Tools.DockTabControl docktab = (dhc.ParentController as
     foreach(DockTabPage tabpage in docktab.TabPages)
         Control siblingcontrol = tabpage.dhcClient.HostControl.Controls[0];
         if(siblingcontrol == this.panel1)
             if(dhost.RectangleToScreen(dhost.TitleBar.CaptionRect).Contains(Cursor.Position) == true)
                 arg.Cancel = true;



Private Sub dockingManager1_DragAllow(ByVal sender As Object, ByVal arg As Syncfusion.Windows.Forms.Tools.DragAllowEventArgs) Handles
    'If the control being dragged is Panel1, then cancel the drag.
    If arg.Control Is Me.panel1 Then
       arg.Cancel = True
       MessageBox.Show("Access denied to drag the window")
    End If
    'If a tab group containing the panel is dragged then, cancel the drag.
    Dim dhost As Syncfusion.Windows.Forms.Tools.DockHost = CType(IIf(TypeOf arg.Control.Parent Is Syncfusion.Windows.Forms.Tools.DockHost,
arg.Control.Parent, Nothing), Syncfusion.Windows.Forms.Tools.DockHost)
    Dim dhc As Syncfusion.Windows.Forms.Tools.DockHostController = CType(IIf(TypeOf dhost.InternalController Is
Syncfusion.Windows.Forms.Tools.DockHostController, dhost.InternalController, Nothing), Syncfusion.Windows.Forms.Tools.DockHostController)
    If TypeOf dhc.ParentController Is Syncfusion.Windows.Forms.Tools.DockTabController Then
      Dim docktab As Syncfusion.Windows.Forms.Tools.DockTabControl = CType(IIf(TypeOf dhc.ParentController Is
Syncfusion.Windows.Forms.Tools.DockTabController, dhc.ParentController, Nothing),
      For Each tabpage As DockTabPage In docktab.TabPages
          Dim siblingcontrol As Control = tabpage.dhcClient.HostControl.Controls(0)
          If siblingcontrol Is Me.panel1 Then
             If dhost.RectangleToScreen(dhost.TitleBar.CaptionRect).Contains(Cursor.Position) = True Then
                 arg.Cancel = True
             End If
          End If
      Next tabpage
    End If
End Sub


Reference link: https://help.syncfusion.com/windowsforms/dockingmanager/docking-events#drag-events

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile