none
Best method to save ribbon control settings (eg check boxes etc) RRS feed

  • Question

  • I got this question from a ms sample project for a VSTO ribbon.  At this point I guess I will load the drop down choices with a data base table, but I think I should save the settings with the app.config file.  Is that the "standard" way to do it? 

    Of course any sample code for working with the app.config would be appreciated.
    Thursday, September 1, 2011 5:36 PM

All replies

  • In your project settings add a variable like "MainChecked" and give it a relevant type, bool in this case. Also default value. This assumes ClickOnce deployment.

     

    Properties.Settings.Default.MainChecked = someButton.Checked;
    ...
    private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
    {
    	Properties.Settings.Default.Save();		

     

    On startup you add some restore code

     

    private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
    {
    	</span>someButton.Checked = </span>Properties.Settings.Default.MainChecked;
    

     

    I apologize for the terrible formatting but I just do not get this websites text edit system.


    Now if you mean you want easy persistence of whole complex nested controls etc. then it is probably worth checking out the various purveyors of custom controls like DevExpress, Telerik, RadControls and so on.
    • Edited by Azethoth Saturday, September 10, 2011 9:38 AM
    Saturday, September 10, 2011 9:32 AM