locked
C# Properties.Settings Problem RRS feed

  • Question

  • All,

    I am using Componant One Studio for WinForms, and I want to save the C1.Win.C1Ribbon quick access toolbar when a user adds to it so that the controls are ready the next time the user launches my application. I have added a Property called `Properties.Settings.Default.QAT` of type 'C1.Win.C1Ribbon.RibbonQat` and upon application shut down I save the QAT like this:

    Properties.Settings.Default.QAT = this.ribbonQat1;
    Properties.Settings.Default.Save();
    

    But this is not doing anything. Im my 'use.config' file I have:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <userSettings>
            <XX.Properties.Settings>
                <setting name="ErrorSearchList" serializeAs="Xml">
                    <value>
                        <ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                            <string>PCT</string>
                            <string>PCT: Mand;</string>
                        </ArrayOfString>
                    </value>
                </setting>
                <setting name="ErrorRegexSearchList" serializeAs="Xml">
                    <value>
                        <ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                            <string>\p{X}</string>
                            <string>\p{2}</string>
                            <string>\w*</string>
                        </ArrayOfString>
                    </value>
                </setting>
                <setting name="QAT" serializeAs="Xml">
                    <value />
                </setting>
            </XX.Properties.Settings>
        </userSettings>
    </configuration>
    

    How should I be saving the details of this control? Also, I attempt to restore it like this:

    this.RibbonQat1 = Properties.Settings.Default.QAT;
    this.Update();
    

    which I gather is not right either? Any help would be most appreciated.


    "Everything should be made as simple as possible, but not simpler" - Einstein
    • Moved by CoolDadTx Monday, January 23, 2012 2:35 PM Winforms related (From:Visual C# General)
    Monday, January 23, 2012 12:30 PM

Answers

  • For custom controls you need to ask the folks that provide it.  We can only help you with MS related technologies here.  I can tell you that the Properties.Settings stuff only works with serializable data.  A ribbon bar is not something that can be serialized via Properties.Settings in all probability.  Every control provider that I've ever worked with provide their own method for persisting settings.  You need to use their documentation to figure it out and/or post a question in the C1 forums to get your answer. 

    Michael Taylor - 1/23/2012
    http://msmvps.com/blogs/p3net

    • Marked as answer by Camuvingian Monday, January 23, 2012 3:13 PM
    Monday, January 23, 2012 2:35 PM

All replies

  • For custom controls you need to ask the folks that provide it.  We can only help you with MS related technologies here.  I can tell you that the Properties.Settings stuff only works with serializable data.  A ribbon bar is not something that can be serialized via Properties.Settings in all probability.  Every control provider that I've ever worked with provide their own method for persisting settings.  You need to use their documentation to figure it out and/or post a question in the C1 forums to get your answer. 

    Michael Taylor - 1/23/2012
    http://msmvps.com/blogs/p3net

    • Marked as answer by Camuvingian Monday, January 23, 2012 3:13 PM
    Monday, January 23, 2012 2:35 PM
  • I'm glad to hear that the question is solved.

    Best wishes,


    Mike Zhang[MSFT]
    MSDN Community Support | Feedback to us
    Tuesday, January 24, 2012 6:38 AM
  • Hello!

    The QatItemNames Gets or sets the string that specifies the list of item names on the QAT. It allows to preserve QAT items added by the user at runtime.

    So I use this code to save and load the items of the QAT:

    //This loads the saved data
    private void PrincipalForm_Load(object sender, EventArgs e)
    {
    c1Ribbon1.QatItemNames = Properties.Settings.Default.QATItems;
    }

    //This saves the items into a property user-defined in the "application configuration file"
    private void PrincipalForm_FormClosing(object sender, FormClosingEventArgs e)
    {
    Properties.Settings.Default.QATItems = c1Ribbon1.QatItemNames;
    Properties.Settings.Default.Save();
    }

    It works very good!

    Saturday, September 6, 2014 2:21 AM