CommandBar Save and Load Layout for WinForms C# Tutorial
The WinForms CommandBar control is a powerful and easy to use user interface control for Windows Forms. This CommandBar control provides large flexibility for developers to customize it. By using the WinForms CommandBar control, developers can add and remove items, rearrange strip elements on different rows elements. The Save and Load layout functionality is able to help developers preserve user settings on location, visibility and orientation in their Windows Forms applications. With the Save layout feature, all the preferences of a user can be kept in an xml file. With the Load layout functionality, users can apply the layout settings to Command Bar.
The following C# Code shows a sample to implement a Save Layout button event handler by using the CommandBar control in Windows Forms template projects. Use the following C# code to initialize the layout.
The following C# code snippets illustrate the process of implementing a Load Layout button event handler in a Windows Forms template projects.
While using the Save and Load layout functionality, developers should pay attention on things that the Load layout will only load the settings for the items that the layout has been saved. The Load layout will not load and recreate the items that had been deleted.
How to Save and Load Scenario of CommandBar
The C# Code snippet below shows a sample to save the layout settings of a CommandBar after closing the parent form of the command bar as well as loading these settings when reopening this form. Normally, developers need to handle the Load and Form Closing events of the form.
UI Controlsfor Windows Forms.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls