mercredi 31 janvier 2018

Trying to set and get Settings.default.XXXXX, passing the XXXX part in code

I have created a setting - Let's say Properties.Settings.Default.LightOn.

I have a form with a bunch of checkboxes and what I want to do is grab the name of the textbox (which matches the name of the setting) and loop through them to update the settings.

Something like where I have passed a checkbox with text = "LightOn"

foreach (CheckBox c in this.form){
string myCtext = c.text;  //This will grab the text

//This is where the problem is...I am not sure how to construct this.  
chk+myCtext+.checked = Settings.Default.+myCtext;

//OR
var myvar = chk+myCtext+".checked = Settings.Default."+myCtext;
myVar;
}

Just not sure how to put it together and I am trying to save myself the steps of having to manually type every assignment out manually.




1 commentaire:

  1. Hello Admin,

    I have a structure with a lot of checkboxes and what I need to do is get the name of the textbox (which coordinates the name of the setting) and circle through them to refresh the settings.

    Regards,
    Thanks

    RITU

    RépondreSupprimer