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
close icon

Auto-Balance Dockingmanager windows

As per the title, I am loading my docking objects (forms) at run time. The user opens a form that loads on the left, so I left dock. The user then opens another form that I dock underneath the previous form. However, the dockingmanager asks for a size, which I can work out based on the fact that it is below one form so formheight/2. I have the option to load many such screens but I would like a way to auto-size each of the panels above/below or left/right to the average width/height of those forms next to it, hope you understand.

How can I work out how many are docked/tabbed together (I might be adding on the middle), anything you guys have done in samples that may help?

13 Replies

AD Administrator Syncfusion Team January 18, 2010 04:07 PM UTC

To add to this, I would like to know what style has been set to a specific form, and can do this using GetDockStyle. This however returns Fill when the form is tabbed with another, I still need to find where that form is docked, something like GetDockStyle(Form.TabbedParent). How can I get the tabbed group control or access to its dockstyle.


NR Nandakumar R Syncfusion Team January 21, 2010 04:25 AM UTC

Hi James,

I regret for the delay in getting back to you. Are you using TabbedGroupedMDIManager/TabbedMDIManager for tabbing the forms that you are loading at run time?

Can you please post a simple application of what you are trying to do, so that I shall work over that and give you the details?

Regards,
Nanda


AD Administrator Syncfusion Team January 21, 2010 09:46 AM UTC

I am using a tabbedMDIManager on the same form, but the case in need solving is non-tabbed entries.

Heres an example:

Dim Button1 As New Button
Button1.Text = "Left"
DockingManager1.DockControl(Button1, Me, Syncfusion.Windows.Forms.Tools.DockingStyle.Bottom, 200)

Dim Button2 As New Button
Button2.Text = "Middle"
Dim intWidth As Integer = Me.Width \ 2
DockingManager1.DockControl(Button2, Button1, Syncfusion.Windows.Forms.Tools.DockingStyle.Right, intWidth)

Dim Button3 As New Button
Button3.Text = "Right"
Dim intSecondWidth As Integer = Me.Width \ 3
DockingManager1.DockControl(Button3, Button2, Syncfusion.Windows.Forms.Tools.DockingStyle.Right, intSecondWidth)


If I set the width for the 3rd panel to 1/3 of the size, the middle panel is squeezed. I need a method to average out each panel, and to do this need to work out which panel is where in relative to its... friend.

So I add Button1 and find nothing else that is docked to the bottom. Next time I add Button2 I find that 1 item is already docked to bottom (I can check this by looping the controlsarray).
So now I need to add the new button at the right size (width /2) which seems to come near the mark.

Then, I add Button3 and find 2 controls, so have to set the width of those existing controls to 1/3 each to allow me to set 11/3 to the new panel. I was wondering how to change the size of tthe panels I find manually,OR if there is a better way to design this. I do not know how many of these Buttons I will have (its a form actually) or where they will go. Might have 4 on the left 3 on the right and 2 floating, its all up to the user.

PS: When I get down to a certain size (ie 100px) I will just maximise the control into the whole space, the idea of this system is to ensure that when a user opens a panel, they can see it, no more than that!!







AutoSizingSample_d1e73def.zip


GS Githanjali S Syncfusion Team January 22, 2010 01:17 PM UTC

Hi James,

Currently there is no option to (automatically)auto balance the controls that are docked to the form.The SetControlSize method can be used for this purpose,as you have done in your sample.I have attached sample according to your requirement and resized in manually.


Regards,
Githanjali



Sample_7675eb4c.zip


AD Administrator Syncfusion Team January 22, 2010 02:17 PM UTC

Thanks for the update, I don't mind modifiying the sizes manually, but I can't tell how many controls I need to be dividing by.

For example, I want to add a 3rd control to the left, so I loop through all controls and see which have a .GetDockStyle of the same type I am about to add, say DockingStyle.Bottom.

But, if 2 controls are tabbed together, I get a docking style of Tabbed returned. How do I know what side is tabbed to? Are there any methods to tell me if something is docked to the main form as opposed to another control, ie a bottomdocked control with another control that has been docked to the top of that?


GS Githanjali S Syncfusion Team January 26, 2010 12:51 PM UTC



AD Administrator Syncfusion Team January 29, 2010 10:31 AM UTC

The sample you have showing how to resize a panel manually does not work. Just change the layout to resize the height instead of the width and it can not deal with it. The height of the top and bottom panels appear to be the same size, but the middle control has been shrunk.


this.dockingManager1.DockControl(this.panel1, this, Syncfusion.Windows.Forms.Tools.DockingStyle.Left, 150);
this.dockingManager1.DockControl(this.panel2, this.panel1, Syncfusion.Windows.Forms.Tools.DockingStyle.Bottom, 150);
this.dockingManager1.DockControl(this.panel3, this.panel2, Syncfusion.Windows.Forms.Tools.DockingStyle.Bottom, 150);

this.dockingManager1.SetControlSize(this.panel1, new Size(150, (this.Height / 3)));
this.dockingManager1.SetControlSize(this.panel2, new Size(150, (this.Height / 3)));
this.dockingManager1.SetControlSize(this.panel3, new Size(150, (this.Height / 3)));



AD Administrator Syncfusion Team January 29, 2010 11:15 AM UTC

And for those that need it, the code to work out where a tabbedgroup is docked is as follows:

'Check if this is on the same size by asking its parent where it thinks it is
If TypeOf objControl.Parent Is Syncfusion.Windows.Forms.Tools.DockHost Then
With DirectCast(objControl.Parent, Syncfusion.Windows.Forms.Tools.DockHost)
If TypeOf .InternalController Is Syncfusion.Windows.Forms.Tools.DockHostController Then
With DirectCast(.InternalController, Syncfusion.Windows.Forms.Tools.DockHostController)
If TypeOf .ParentController Is Syncfusion.Windows.Forms.Tools.DockTabController Then
With DirectCast(.ParentController, Syncfusion.Windows.Forms.Tools.DockTabController)
If .DockEdge = objSyncDockStyle Then
arrDockedPanelBuddies.Add(objControl)
If TypeOf objControl Is frmPanelFormBase Then
'Check if it is a better match for this new panel
If objLinkedControl Is Nothing Then
objLinkedControl = DirectCast(objControl, frmPanelFormBase)
objLinkedControlDockStyle = .DockEdge
Else
If Math.Abs(DirectCast(objControl, frmPanelFormBase).PanelDesignPosition - PanelLayoutInfo.Position) <= Math.Abs(DirectCast(objLinkedControl, frmPanelFormBase).PanelDesignPosition - PanelLayoutInfo.Position) Then
objLinkedControl = DirectCast(objControl, frmPanelFormBase)
objLinkedControlDockStyle = .DockEdge
End If
End If
End If
End If
End With
End If
End With
End If
End With
End If


AD Administrator Syncfusion Team January 29, 2010 11:25 AM UTC

And for those that need it, the code to work out where a tabbedgroup is docked is as follows:

If TypeOf objControl.Parent Is Syncfusion.Windows.Forms.Tools.DockHost Then
With DirectCast(objControl.Parent, Syncfusion.Windows.Forms.Tools.DockHost)
If TypeOf .InternalController Is Syncfusion.Windows.Forms.Tools.DockHostController Then
With DirectCast(.InternalController, Syncfusion.Windows.Forms.Tools.DockHostController)
If TypeOf .ParentController Is Syncfusion.Windows.Forms.Tools.DockTabController Then
With DirectCast(.ParentController, Syncfusion.Windows.Forms.Tools.DockTabController)
Debug.Print(.DockEdge)
End With
End If
End With
End If
End With
End If



PS: Please delete previous post


AD Administrator Syncfusion Team January 29, 2010 02:06 PM UTC

The code I posted above seems to have an issue. If I have 2 controls tabbed together, then 2 more controls tabbed together all on the bottom. The .DockEdge says bottom for the first tab set, then right for the second tab set. Any clues on how to get bottom and bottom?


AD Administrator Syncfusion Team January 29, 2010 02:23 PM UTC

It appears I can not tell where a DockTabController is, the .DockEdge property is giving me the answer of Right, when it is at the bottom, this is with only 1 tab set not 2.


AD Administrator Syncfusion Team February 1, 2010 02:38 PM UTC

For those who need it, the property that tells you where the tab group is docked is actually

.DICurrent.dStyle


GS Githanjali S Syncfusion Team February 2, 2010 01:56 PM UTC

Hi James,

Hope your issue is solved through the direct incident created with respect to this forum.

Regards,
Githanjali

Loader.
Live Chat Icon For mobile
Up arrow icon