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.
Unfortunately, activation email could not send to your email. Please try again.

Save the menu state to the default location

Thread ID:





45259 Jun 15,2006 07:30 AM Jun 17,2006 02:51 AM Windows Forms 2
Tags: Tools
David Vanstone
Asked On June 15, 2006 07:30 AM

I wish to hide a toolbar from code. After which I wish to persist the state of the toolbar, so when I next open the application the toolbar remains hidden. However I am have trouble do this. When I hide the toolbar from using the Toolbar list popup it works, but not from code. I am using the following method for saving the state, but appears not to be working. //save the changes, AppStateSerializer serializer = AppStateSerializer.GetSingleton(); mBarManager.SaveBarState(serializer);

David Vanstone
Replied On June 16, 2006 09:47 AM

Changed my code to mBarManager.GetCommandBarManager().SetBarVisibility(bar,visible);

J.Nagarajan [Syncfusion]
Replied On June 17, 2006 02:51 AM

Hi David, The SaveBarState/LoadBarState methods persist the positional information of the menus/toolbars only. Hiding/showing or adding/removing BarItems/toolbars amounts to menu customization and the MainFrameBarManager''''s protected methods - LoadCustomizationInfo / SaveCustomizationInfo handle this.You have to derive a custom mainframeBarManager and use these methods to persist customization. Set the following properties to false and then load the state from a serialized file. This way all the state persistance is done to the same xml file. this.mainFrameBarManager1.AutoLoadToolBarPositions = false; this.mainFrameBarManager1.AutoPersistCustomization = false; //to programatically hide the bars mainFrameBarManager1.GetCommandBarManager().SetBarVisibility(bar1,false); mainFrameBarManager1.GetCommandBarManager().SetBarVisibility(bar2,false); I have attached a sample which demonstrate this completely.In this sample when you click on "New" baritem the bar1 and bar2 will be hidden.When you click on "save" and "Load" buttons to save and load the customized informations. Please let me know if this meets your requirements. Thank you, J.Nagaraj. persistCustomization.zip


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.