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

DockingManager

Hey guys

I am writing some code that extracts properties from the Docking Manager based on the position of the controls on the screen.

I can dock two controls - one to the top and one to bottom and then look at the DockStyle of the two controls - one correctly states Top and the other states Bottom. Perfect. I can then get the Size of the control and persist the height for those with a docking style of Top or Bottom. And persist the width for those docked Left or Right. Perfect again.

The problem I have surrounds when I dock the first control to the top - and then dock the second within the first to the right. So that they are both docked to the top and appear one to the right and one to the left. (see below)

__________
|____|____|
| |
| |
| |

when I enquire for the docking style (GetDockingStyle(ctrl)), both return TOP. I assume that I need to work the path of the created dock panels and enquire the docking state of the panels rather than the controls. If I SaveDockingLayout() to xml, I see the docking styles are set to Right and Fill, as I would expect. Question is - how do I extract that information for myself by interacting with the docking manager??


Regards

Matt Speller

23 Replies

RB Rajasekar B Syncfusion Team March 22, 2010 01:39 PM UTC

Hi Matt,

Thank you for your interest in syncfusion product.

To get the docking style of a control and to which control does it docked, you can use DragDockInfo property.

Below is the sample code:

if (this.dockingManager1.GetDockVisibility(this.panel1))
{
DockHost dhc = this.panel1.Parent as DockHost;
String str= dhc.DragDockInfo.dStyle.ToString();
}

dStyle returns the style.

Please let me know if you have any question.

Thanks,
Rajasekar



DockingMgr_bfd3827e.zip


AD Administrator Syncfusion Team March 22, 2010 04:24 PM UTC

If its any use I needed the same thing for a different reason, check the thread here:

http://www.syncfusion.com/support/forums/tools-windows/92476/auto-balance-dockingmanager-windows

and you can see I needed to work out where a control was docked to regardless of it being tabbed-docked with another control. The code finds the tabbed panel set and extracts the panels style(position) not the actual controls style(position).


MS Matt Speller March 22, 2010 04:55 PM UTC

Thanks guys, will check it out and feed back.

Matt


RB Rajasekar B Syncfusion Team March 25, 2010 11:53 AM UTC

Hi Matt,

Thanks for the update.

Thanks,
Rajasekar


MS Matt Speller March 25, 2010 02:56 PM UTC

Hey Rajasekar,

Your post is exactly what I am after. That is the docking style I would like to persist. One other bit of information I require is to capture within what control it is docked.

For example if I add A and then dock B to the right within A, the dockstyle (using your helpful code) returns Right. Excellent! But how do I tell that it is docked within A? By examining the DragDockInfo I cannot tell this information.

When I try to recreate the docking at a later date, knowing A is docked top and B is docked right will not give me the same layout as docking B to the right inside of A.

Any further pointers would be great.

Matt


RB Rajasekar B Syncfusion Team March 26, 2010 01:40 PM UTC

Hi Matt,

You can use the following code

DockHost dhc = this.treeView1.Parent as DockHost;
dhc.DragDockInfo.dController.HostControl.Controls[0].

It will return the control to which treeview is docked.

Please let me know if you have any question.

Thanks,
Rajasekar



DockingMgr_877623aa.zip


AD Administrator Syncfusion Team March 29, 2010 03:07 PM UTC

In case you have not seen it, there is a built in method to load/save a layout, something like this:

http://www.syncfusion.com/support/kb/1395/How-do-I-persist-dockstate-in-a-DataBase


MS Matt Speller March 31, 2010 09:34 AM UTC

Many thanks Rajasekar,

having played with the code, I think I have found a couple of bugs. In a set of circumstances the DockHost does not report the correct docking style for the controls. Maybe there is a call to the DockingManager to refresh the state that I am missing.

Please look at your modified project you will find attached. Using the method you suggested earlier on this post, I cast the Parent of the docked control to the DockHost and then query the DragDockInfo.dStyle to attain the docking style. This works perfectly in most cases.

In the modified soultion I have added another message box when the user presses the 'Treeview Docked To' menu button that reports the treeview1 dock style.

If you follow the set of circumstances below, the one or both message boxes report the wrong information:

Issue 1.
Press 'Treeview Docked To' - correctly reports dock parent as main form, but suggests DockStyle is left - in fact it is TOP.

Issue 2.
dock treeview2 to right of main form.
dock treeview1 to bottom of treeview 2.
Press 'Treeview Docked To' - correctly reports dock parent as treeview2 and style as Bottom.
dock treeview2 to bottom of main form.
Press 'Treeview Docked To' - incorrectly reports dock parent as treeview2 and style as Bottom. It should now be docked to main form and dock style of right.

Please can you suggest the method I should use to solve this issue.

Matt




DockingMgr_fe8bf02f.zip


VS Vallarasu S Syncfusion Team April 7, 2010 10:16 AM UTC

Hi Matt,

Regret for the delay. We are analyzing this behavior in DockingManager and will update you the details in a week.

Regards
Vallarasu s.


MS Matt Speller April 12, 2010 12:36 PM UTC

Many thanks - awaiting confirmation of the fault and a suggested workaround / patch.


VS Vallarasu S Syncfusion Team April 13, 2010 09:26 AM UTC

Hi Matt,

Thanks for the patience.

You can get the dockstyle and the control to which another control has been docked to, using the below code,

DockHost dh = checkedListBox1.Parent as DockHost;
DockHostController dhc = dh.InternalController as DockHostController;
DockTabController dtc = dhc.ParentController as DockTabController;
MessageBox.Show("Dock Style : " + dhc.DICurrent.dStyle.ToString());
if (dtc != null)
{
MessageBox.Show("Tabbed in :" + dtc.TabControl.Name.ToString() + " with :" +dtc.HostControl.Controls[0].Name);
}
MessageBox.Show("Docked To :" + dhc.DICurrent.dController.HostControl.Name);
if (dh.DragDockInfo.dController is DockHostController)
MessageBox.Show("At the :" + dh.DragDockInfo.dStyle.ToString()+ " side of "+ dh.DragDockInfo.dController.HostControl.Controls[0].Name);


Please refer the sample in below link which demonstrates the above.

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=DockingmanagerDockinfo369487030.zip

Please let me know if it helps.

Regards
Vallarasu S.


MS Matt Speller April 15, 2010 10:03 AM UTC

Hi

The code you suggest does not resolve the issues I mentioned in incident.

If I dock the checkedlistbox to the right of the month calendar, then press Get Dock Info Check List button, I get three message boxes. 1. "Dock style Left" no - it is set to right 2. "Docked to form 1" no - it is docked to the month calendar. 3. To the right side of monthcalendar1. Yes! So that looked ok.

Then I moved the month calendar to be docked at the bottom after docking the checkedlistbox1 to the right of the calendar first. The 3 message box still reports it is docked to the right side of the monthCalendar1. This is incorrect.

Please read my initial posting that explained the issues clearly. Your attached soultion did not solve the issues.

See attached screen shots.

Matt



DockManager Incorrect Dock Style Reporting_721a8a88.zip


RB Rajasekar B Syncfusion Team April 22, 2010 07:03 PM UTC

Hi Matt,

Thanks for your patience,

We have worked around it in a sample to get the Docking style and the control to which it is docked. Please let us know if this helps you.

Thanks,
Rajasekar



DickingInfo_2d6092f4.zip


MS Matt Speller April 27, 2010 12:18 PM UTC

Marvellous - I will look at the code and see it if is satisfactory.


LS Lingaraj S Syncfusion Team April 30, 2010 03:44 AM UTC

Hi Matt,

Thank you for your update and participation in Syncfusion’s Community Forums.

Please let me know if you have any queries.

Regards,
Lingaraj S.


MS Matt Speller May 11, 2010 02:41 PM UTC

Hi guys,

I am afraid there is still an issue. It's rather more serious than before, as the dockingmanager/host ends up saying that two controls are parents of each other.

It has taken me a while to chase down the steps to recreate, please find the attached word document that shows the screens step by step.

I assume there will be more code around line 73 of the code supplied or further code in the DockStateChanging method to refresh the dock parent.

Please advise asap as to the estimated time to provide a work around. Please recreate with code example attached to your last reply to me.

Regards

Matt Speller



dockleftthenright_a571bb0e.zip


LS Lingaraj S Syncfusion Team May 12, 2010 06:06 PM UTC

Hi Matt,

Thank you for the update.

We are able to see the issue mentioned issue in Docking Manger. We working on this and will update you the solution ASAP.

Regards,
Lingaraj S.


MS Matt Speller May 18, 2010 03:20 PM UTC

Any update please?


LS Lingaraj S Syncfusion Team May 18, 2010 07:03 PM UTC

Hi Matt,

Thank you for the update.

I have modified the sample logic to retrieve the DockStyle and DockedControl of control.
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=DockingInfo-2093360639.zip

Please have look at the above modified sample and let me know if you face any issues.

Regards,
Lingaraj S.


MS Matt Speller August 24, 2010 03:38 PM UTC

Hi there,

Having used the workarounds discussed in this thread for the last couple of months, they seem to account for 90% of the usage. There is a scenario that does cause the Docking Information to report incorrectly still. Please use the attachment from your last post to me.

Please follow the steps in the attached word doc. The first set show it working properly and the second set show how setting the controls to be tabbed before repeating the same actions cause the dock info to become confused.

Please advise how to change your code in the previous forum post, to cover this scenario.

Regards

Matt Speller




Load up test app_f2f6f13c.zip


LS Lingaraj S Syncfusion Team August 25, 2010 01:50 PM UTC

Hi Matt,

Thank you for the update.

Please try use DINew in GetStyle method to solve this issue.

private void GetStyle(Control con)
{
// other codes
else
{
MessageBox.Show("Dock Style : " + dhc.DINew.dStyle.ToString());
if (dhc.DINew.dController.HostControl != null)
{
MessageBox.Show("Docked At :" + dhc.DINew.dController.HostControl.Name);
}
else
{
MessageBox.Show("Docked At :" + dhc.DICurrent.dController.HostControl.Name);
}
}
}


Refer the sample from following link.
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=DockingInfo_8_25-397086899.zip

Please let me know if you have any queries.

Regards,
Lingaraj S.


MS Matt Speller August 27, 2010 02:05 PM UTC

Thanks for the update. Unfortunately the code does not deal with the attached scenario.

Please advise how best to use your code to get the correct dock parent in all cases. The code you supplied does give the correct dock style. Parent is incorrect though.

From my tests I see that the DockHost is not always a DockHostController, it can be a MainFormController or a DockTabController. I think this if statement in your logic flow is where it fails. The DockHost USED to be a DockTabController and when moved, it is infact a DockHostController but the DockHost property still states it is a DockTabController - hence it returns the wrong parent.

Matt



issue_9b12e3fa.zip


LS Lingaraj S Syncfusion Team September 3, 2010 11:33 AM UTC

Hi Matt,

Regret for the delayed response.

You have created DirectTrac incident for this query. Please followup your queries with incident (#71738).

Please let me know if you have any other concerns.

Regards,
Lingaraj S.


Loader.
Live Chat Icon For mobile
Up arrow icon