)
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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to prevent docking windows from being docked to certain sections of the host form in WinForms Docking Manager?

Platform: WinForms |
Control: DockingManager |
Published Date: April 30, 2011 |
Last Revised Date: December 9, 2019

Docking events

The DockingManager has two very powerful events - DragAllow and DockAllow - that can be used separately or in tandem to tailor your application’s docking behavior. The DragAllow event is fired just before a drag operation commences while the DockAllow event is generated during the course of a drag operation when the dragged control is moved over a potential dock target. Both events allow for pre-emption and thus drag/dock operations may be deemed as allowed or otherwise based on the event arguments.

Two scenarios for the DockAllow event are shown below

C#

// DockingManager.DockAllow event handler in the Form hosting the DockingManager - Case 1
private void dockingManager1_DockAllow(object sender, Syncfusion.Windows.Forms.Tools.DockAllowEventArgs arg)
{
    // Disallow all controls from being docked to the host Form’s left border
    if((arg.TargetControl == this) && (arg.DockStyle == Syncfusion.Windows.Forms.Tools.DockingStyle.Left)) 
       arg.Cancel = true;
}
// DockingManager.DockAllow event handler - Case 2
private void dockingManager1_DockAllow(object sender, Syncfusion.Windows.Forms.Tools.DockAllowEventArgs arg)
{
    //Disallow the dwNetwork docking window from being docked to the host Form’s left border
    if((arg.TargetControl == this) && (arg.DragControl == this.dwNetwork) && (arg.DockStyle == Syncfusion.Windows.Forms.Tools.DockingStyle.Left))
       arg.Cancel = true;
}

 

VB

' DockingManager.DockAllow event handler in the Form hosting the DockingManager - Case 1
Private Sub dockingManager1_DockAllow(ByVal sender As Object, ByVal arg As
Syncfusion.Windows.Forms.Tools.DockAllowEventArgs) Handles dockingManager1.DockAllow
    If (arg.TargetControl Is Me) AndAlso (arg.DockStyle =
Syncfusion.Windows.Forms.Tools.DockingStyle.Left )
Then
       arg.Cancel = True
    End If
End Sub
'DockingManager.DockAllow event handler - Case 2
Private Sub dockingManager1_DockAllow(ByVal sender As Object, ByVal arg As
Syncfusion.Windows.Forms.Tools.DockAllowEventArgs) Handles dockingManager1.DockAllow
    If (arg.TargetControl Is Me) AndAlso (arg.DragControl Is Me.panel1) AndAlso (arg.DockStyle = Syncfusion.Windows.Forms.Tools.DockingStyle.Left)
Then
       arg.Cancel = True
    End If
End Sub

 

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

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
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
Live Chat Icon