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

Prevent docking onto main form

I have a Form, which contains the DockingManager. Is there a way to disable docking to the main form? I have disabled the the caption bar and double click on captions. Which seems not to allow any docking on to the main form, but If you have several controls that are docked to each other in a Tabbed Style, double clicking on the tab will dock the control to the main form.

3 Replies

RC Rajesh C Syncfusion Team May 18, 2007 01:59 AM UTC

Hi Peter,

You can prevent docking to Main Form when the dock Tab or floating window's caption bar is double clicked . Please refer to the following code snippets which illustrates the same:

[ C# ]


//To prevent docking to Main Form when the floating window's caption bar is double clicked.

this.dockingManager1.EnableDoubleClickOnCaption = false;

// To prevent docking to Main Form when the dock Tab is double clicked.

private void dockingManager1_DragAllow(object sender, DragAllowEventArgs arg)
{
DockHost dhost = arg.Control.Parent as DockHost;
DockHostController dhc = dhost.InternalController as DockHostController;

if (dhc.ParentController is DockTabController)
{
DockTabControl docktab = (dhc.ParentController as DockTabController).TabControl;
foreach (DockTabPage tabpage in docktab.TabPages)
{
if (dockingManager1.IsTabbed(arg.Control))
{
if (!dhost.RectangleToScreen(dhost.TitleBar.CaptionRect).Contains(Cursor.Position) )
{
arg.Cancel = true;
}
}
}
}
}



Please have a look at this sample and let me know if this helps you.

http://websamples.syncfusion.com/samples/Tools.Windows/I34124/Main.htm

Thank you for using Syncfusion products.

Regards,
Rajesh C



AB Ankur Badola July 9, 2007 08:26 AM UTC


Hi, How can I prevent a floatingform (which contains multiple controls docked in) from getting docked to the main form? The DragAllow event does not work in this case.
I am using Syncfusion version 4.2.

Thanks,
Ankur

>Hi Peter,

You can prevent docking to Main Form when the dock Tab or floating window's caption bar is double clicked . Please refer to the following code snippets which illustrates the same:

[ C# ]


//To prevent docking to Main Form when the floating window's caption bar is double clicked.

this.dockingManager1.EnableDoubleClickOnCaption = false;

// To prevent docking to Main Form when the dock Tab is double clicked.

private void dockingManager1_DragAllow(object sender, DragAllowEventArgs arg)
{
DockHost dhost = arg.Control.Parent as DockHost;
DockHostController dhc = dhost.InternalController as DockHostController;

if (dhc.ParentController is DockTabController)
{
DockTabControl docktab = (dhc.ParentController as DockTabController).TabControl;
foreach (DockTabPage tabpage in docktab.TabPages)
{
if (dockingManager1.IsTabbed(arg.Control))
{
if (!dhost.RectangleToScreen(dhost.TitleBar.CaptionRect).Contains(Cursor.Position) )
{
arg.Cancel = true;
}
}
}
}
}



Please have a look at this sample and let me know if this helps you.

http://websamples.syncfusion.com/samples/Tools.Windows/I34124/Main.htm

Thank you for using Syncfusion products.

Regards,
Rajesh C



JS Jeba S Syncfusion Team July 16, 2007 01:27 PM UTC

Hi Ankur,

You can handle the DockingManager.DockAllow event and based on the DockAllowEventArgs parameter, either allow or cancel the event. The DockAllow event will only enable you customize dock/dock-in-float operations. The controls will still be free to float as a unique floating window.


void dockingManager1_DockAllow(object sender, DockAllowEventArgs arg)
{
//Not allow the panel1 to dock in floating mode
if (dockingManager1.IsFloating(this.panel1 ))
{
arg.Cancel = true;
}
}



Please refer the sample in the below link which illustrates the above:
http://websamples.syncfusion.com/samples/Tools.Windows/F61032/main.htm

Thank you for using Syncfusion Products.

Kindly let us know if you need any further assistance.

Best Regards,
Jeba.

Loader.
Live Chat Icon For mobile
Up arrow icon