Please note: In an effort to better serve you, we are in the process of restructuring DevCenter. In the process, we have moved many items that you may be used to finding in DevCenter over to the Main Site. If you are having trouble locating something, please try looking at the following places:
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.
...ContinuedUntil this point, we have covered how to load a Dock layout if one exists. Now we will cover how to save a layout during the application’s use.In a standard Windows Forms application where all of the user interface components and events are accessible from within the application, we would normally handle the main form’s FormClosing event and in this event, we can simply call the DockManager.SaveAsXML( ) method to save it easily. Due to the nature of working with CAB and the nested SmartParts and Workitems, it is not so simple to handle this situation in the same way. To handle this scenario, we can listen to the events fired by the UltraDockWorkspace whenever we make a change to its controls and then we can save the Layout. This means that whenever we pin, dock, float or resize any of the controls, we will be saving the Layout. This should not raise any concerns because it does not happen so often. If you are saving the layout as a stream and writing it to a remote database somewhere, then this may introduce some performance related issues, so as an alternative, you can always save to a file on disk and when the application closes, you can stream the file to the database just once. Here are the UltraDockWorkspace events that are being used to save the Dock layout:
The actual implementation code to save the layout is as follows (for Model View Presenter, this should be implemented in the presenter, not the view):
Running the sampleTo run the application, take the following steps:1. Run the application2. Pin, Unpin, Dock and manipulate the controls3. Close the application (close the window)4. Run the application againResults:Notice how the Dock Layout is maintained across different run sessions. Review:Now that we have learned how to load and save Dock layouts, we can incorporate this functionality into our NetAdvantage powered CAB applications. Please download the source code and review the code and comments to see this implementation in action.