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

Saving Toolbars location to xml

Hi,

Is there any way we can serialize the Toolbars location and any other related info to an XML file other than Isolated Storage?

Regards
Vijay

5 Replies

GS Gopalakrishnan S Syncfusion Team February 19, 2007 08:37 PM UTC

Hi Vijay,

Thanks for using Syncfusion products.

You can use BarManager's SaveBarState() and LoadBarState() method to save and load the toolbar states. If you want to persist the bar state into a local folder instead of Isolated Storage, first you have to set the MainFrameBarManager's AutoPersistCustomization and AutoLoadToolBarPositions property to false.

Here is the code snippet:

// Load the Saved Bar Information
private void Form1_Load(object sender, System.EventArgs e)
{
AppStateSerializer serializer = new AppStateSerializer(SerializeMode.XMLFile, "..//..//StateInfo");
this.mainFrameBarManager1.LoadBarState(serializer);
}

// Save the Bar State Information
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
AppStateSerializer serializer = new AppStateSerializer(SerializeMode.XMLFile, "..//..//StateInfo");
this.mainFrameBarManager1.SaveBarState(serializer);
serializer.PersistNow();
}

Sample

Please refer to the attachments and let me know if you have any questions.

Regards,
S.Gopal.


KZ Klaus Ziegler October 23, 2007 01:25 PM UTC

Hello,

I would also work without the isolated storage and use the method LoadBarState and SaveBarState. I would like to customize a toolbar and the mainmenu, e.g. rename a menuentry. If I set the AutoPersistCustomization = true all works fine, but the information is saved in xml-file and the isolated storage. If I set the AutoPersistCustomization = false nothing works. The information is in the xml-file and nothing in the isolated storage, but if I restart the application, this means I load the bar state, the customization is lost.
How can I work with a XML-File without using the isolated storage.
I tested this also with the sample "Windows\Diagram.Windows\Samples\2.0\In Depth\DiagramBuilder".

Regards
Klaus


JS Jeba S Syncfusion Team October 25, 2007 11:36 AM UTC

Hi Klaus,

Please follow the Direct-Trac incident 38563 for this query.

Thank you for using Syncfusion Products.

Best Regards,
Jeba.


CS Craig Stephens November 9, 2007 10:48 PM UTC

I'm having the same type of problem as Klaus. Has there been any resolution?

Using the sample application provided in this thread:

1. Open app.
2. Remove a button from the toolbar.
3. Close app.
4. Open app.
5. Button that was removed is back when it should not be.



J. J.Nagarajan Syncfusion Team December 28, 2007 11:22 PM UTC

Hi Craig ,

The SaveBarState/LoadBarState methods deal with 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.

So in your sample you should set

this.mainFrameBarManager1.AutoLoadToolBarPositions = false;
this.mainFrameBarManager1.AutoPersistCustomization = false;

and then load the state from the serialized file. The way all the state persistance is done to the same xml file.

http://websamples.syncfusion.com/samples/Tools.Windows/F56696/main.htm

Please take a look at the sample and let me know if you have any questions. Thanks.

Best regards,
Nagaraj


Loader.
Live Chat Icon For mobile
Up arrow icon