How to get the individual Docked control’s properties?
9 Dec 20193 minutes to read
To check whether a control is floating or docked, you could use the code snippet given below.
To get the Dock location
- Add a list view and a docking manager in your form.
- Enable the list view as a docked control.
- Now add the below given code in your form’s constructor.
//listView1 is the dockable control. We could get it's dock properties by accessing DockHost and DockHostController. Syncfusion.Windows.Forms.Tools.DockHost dockHost = this.listView1.Parent as Syncfusion.Windows.Forms.Tools.DockHost; Syncfusion.Windows.Forms.Tools.DockHostController dockHostController = dockHost.InternalController as Syncfusion.Windows.Forms.Tools.DockHostController; //The DockInfo object will give all the information about docked control. Syncfusion.Windows.Forms.Tools.DockInfo dockInfo = dockHostController.GetSerCurrentDI(); MessageBox.Show(dockInfo.dStyle.ToString() + dockHostController.LayoutRect.ToString());
' listView1 is the dockable control. We could get it's dock properties by accessing DockHost and DockHostController. Dim dockHost As Syncfusion.Windows.Forms.Tools.DockHost = CType(IIf(TypeOf Me.listView1.Parent Is Syncfusion.Windows.Forms.Tools.DockHost, Me.listView1.Parent,Nothing), Syncfusion.Windows.Forms.Tools.DockHost) Dim dockHostController As Syncfusion.Windows.Forms.Tools.DockHostController = CType(IIf(TypeOf dockHost.InternalController Is Syncfusion.Windows.Forms.Tools.DockHostController, dockHost.InternalController, Nothing), Syncfusion.Windows.Forms.Tools.DockHostController) ' The DockInfo object will give all the information about docked control. Dim dockInfo As Syncfusion.Windows.Forms.Tools.DockInfo = dockHostController.GetSerCurrentDI() MessageBox.Show((dockInfo.dStyle.ToString + dockHostController.LayoutRect.ToString))
4.Before closing a docked / floating control, access the control’s parent and cast this to type Syncfusion.Windows.Forms.Tools.DockHost.
- Now access the DockHost’s InternalController and get it’s current serialization info by using the GetSerCurrInfo() method. This will fetch an object of type Syncfusion.Windows.Forms.Tools.DockInfo. The DockInfo.DockingStyle member gives the dock position of the particular control with respect to the host form and the DockInfo.rcDockArea member returns the control bounds.
- If the control is floating, then DockingStyle will be equal to Syncfusion.Windows.Forms.Tools.DockingStyle.Fill. You can serialize this information against the control’s name and later upon loading, appropriately use either the DockingManager.DockControl() / FloatControl() method, based on the serialized DockingStyle and control’s bounds values, to set the control’s dock state.