Hi,
I have been looking at your KB09844 article and accompanied source code for the past few days now trying to make sense of it all. All I want to do is, at runtime open a user control in the main form if it was opened when the application was last closed, using the loadFromXml method. Thats it. Is there not an easier way of doing this than having to implement the ControlledWorkItem, WorkItemController, Module, ModuleController, RootViewPresenter etc. classes??? I know that previously we were using DevExpress and it was as simple as saving the layout when exiting and all forms that were opened would be saved. Any help or examples would be appreciated.
Thanks.
When loading a layout, the UltraDockManager requires that the controls that were docked when saving the layout are somewhere on the control the dock manager is hosted in. If any controls are not present, they will not be loaded. There is a good chance the docked controls will have state information, and the dock manager cannot store that info when saving the layout, so it cannot recreate these controls with their correct state automatically. You can also submit a feature request for an event that gets fired when loading a layout and a control to create a loaded pane cannot be found: http://devcenter.infragistics.com/Protected/RequestFeature.aspx. This will prevent the need from having the control on the form when the dock manager is loaded.
Thanks for the quick reply, but that didn't really solve my problem. Here is a very basic example of what I am trying to do.
public partial class Form1 : Form { private DockAreaPane m_dockAreaLeft = null; public Form1() { InitializeComponent(); if( !File.Exists( "C:\\Documents and Settings\\orrie.shannon\\Desktop\\settings.txt" ) )
{ m_dockAreaLeft = new DockAreaPane( DockedLocation.DockedLeft ); m_dockAreaLeft.ChildPaneStyle = ChildPaneStyle.HorizontalSplit; DockWorkspace.DockAreas.Add( m_dockAreaLeft ); DockableControlPane testPane = new DockableControlPane(); testPane.Text = "test"; testPane.Control = new TestUserControl(); //where TestUserControl is a very basic UserControl with no functionality m_dockAreaLeft.Panes.Add( testPane ); } else { DockWorkspace.LoadFromXML( "C:\\Documents and Settings\\orrie.shannon\\Desktop\\settings.txt" ); } } private void Form1_FormClosed( object sender, FormClosedEventArgs e ) { this.DockWorkspace.SaveAsXML( "C:\\Documents and Settings\\orrie.shannon\\Desktop\\settings.txt" ); } }
The first time this is run the testPane appears docked on the left hand side as it should, and it seems as though the it is being saved in the xml file ( from the line "<Text id="ref-18">test</Text>" ). But, when DockWorkspace.LoadFromXML() is called this pane does not re-appear. What am I doing wrong?
First of all, for the load functionality to work correctly, the Name of the docked control must be non-null and not empty and unique to all other controls docked in the dock manager. Also, when you call LoadFromXml, a control with that unique name must be on the Form (somewhere in its Controls collections or nested in another control's Controls collection which is on the Form). So you must make sure to set the Name of the TestUserControl instance before saving the layout, and you must create a new TestUserControl with that Name and add it to the Form before loading the layout.
Hi ,
Can you privide me the link for the article KB009844 metoined in the discussion .
I am having serious issue while loading the views .
Thanks,
Ashish.
You don't necessarily have to use smart parts, but its just an easy way to have the controls on the Form when you load a layout. You can manually create controls and add them to the controls collection of the Form or a contorl within in without using smart parts.
Wow thanks, that helps a lot. Just for my own curiosity, in what situation would you use the UltraDockWorkspace as described in KB009844. It says that "The UltraDockWorkspace provides a rich, powerful way of managing SmartParts so that end users can dock, pin, hide, show and float user interface components to their liking. This article shows how to save these customizations so that the next time the users run the application, it will be the same as the last time they closed it." If you can load and save layouts just from using the LoadFromXML() and SaveAsXML() methods, when would you need to use smart parts?