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

Persisting DockingManager control sizes

I am trying to persist the width of a GroupBar panel docked inside a DockingManager instance across sessions. I am aware of the DockingManager.PersistState flag, but I need to control the location of the state because of other requirements that are too arcane to describe. In my Form.OnClosing() override I save the width of the GroupBar Control. OK so far. During Form.OnLoad() I tried to restore the width using DockingManager.SetControlSize() but this didn''t work. I sort of got something to work by setting a state flag and then calling SetControlSize() in one of the OnActivated() calls. But then if I create another instance of the main Form, things don''t work. My question is. If I know the desired width of a docked Control, what is the best way to re-initialize this size when the Form is created?

2 Replies

AD Administrator Syncfusion Team April 8, 2005 03:39 PM UTC

Hi Peter, I''d recommend looking into the LoadDockState() and SaveDockState() methods in DockingManager. They should provide you with the control over persistance that you''re looking for. Please let me know if you have any questions regarding the use of these methods. Regards, Gregory Austin Syncfusion Inc.


PM Peter Moss April 11, 2005 07:41 PM UTC

Gregory, Thank you for the tip. That is what I ended up doing. The one subtle point is that after loading the state (duing the Form.OnLoad() override), I had to call dockingManager.RecalcHostFormLayout() because otherwise the contained Control had the default designer width instead of the full width of the splitter bar. Here is some code that I am using in case anyone else is interested: private void SerializeDockingManagerState(bool bSave) { string dockingManagerStatePath = AbdUtils.PathAppend2(AbdUtils.GetUserSettingsPath(false), @"DockingManagerState.xml"); try { if (bSave) { using (FileStream fs = new FileStream(dockingManagerStatePath, FileMode.Create, FileAccess.ReadWrite)) { Syncfusion.Runtime.Serialization.AppStateSerializer ser = new Syncfusion.Runtime.Serialization.AppStateSerializer(Syncfusion.Runtime.Serialization.SerializeMode.XMLFmtStream, fs); dockingManager.SaveDockState(ser); ser.PersistNow(); fs.Close(); } } else { using (FileStream fs = new FileStream(dockingManagerStatePath, FileMode.Open, FileAccess.ReadWrite)) { Syncfusion.Runtime.Serialization.AppStateSerializer ser = new Syncfusion.Runtime.Serialization.AppStateSerializer(Syncfusion.Runtime.Serialization.SerializeMode.XMLFmtStream, fs); dockingManager.LoadDockState(ser); } // I found I needed to call this because the containd GroupBar control is not resized to the proper splitter bar position/width dockingManager.RecalcHostFormLayout(); } } catch (Exception e) { s_log.Warn("SerializeDockingManagerState AppStateSerializer error.", e); } }

Loader.
Live Chat Icon For mobile
Up arrow icon