Have this code in place:
private void button32_Click(object sender, EventArgs e)
{
string Current = textBox23.Text;
label60.Text = Current;
int SaveRate = Convert.ToInt32(Current);
SaveRate = Properties.Settings.Default.PriorExclTimer;
Properties.Settings.Default.Save();
}
Code updates the label fine, but it doesn't update App.config and save the new setting. The setting type is PriorExclTimer, and it is stored as int. Not sure what I need to do to add the value and save it to the App.config xml.
One unintended thing happens with this code. When the program opens using Start, somehow the label remembers the last number typed in textBox23, even though the xml is not changing when the button is pressed (xml contains a different value than what shows in label60 on Start unless the last number used from the textBox was the same one as what is in the xml).
Some info. In the form.cs, I have added some code below the initialization statement that converts the int in App.config to string, so it can be added to the label (label 60) when the program starts. I was intending to use this methodology for several label controls. Here is all of the opening form.cs:
public HyperFlexTest()
{
InitializeComponent();
Load += new EventHandler(HyperFlexTest_Load);
int ExclRate = Properties.Settings.Default.PriorExclTimer;
label60.Text = ExclRate.ToString();
}
Could this be affecting the later control code? Very curious about what causes the last number typed in textBox23 to persist, even past a restart of VS 2015 and even though the number doesn't match the number in the xml file.
I would also like to null the textBox (textBox23) value when the button is pressed.
Thanks
EDIT: The referenced thread question mentioned as a possible duplicate concerns the location of the settings file. My question is about about code context and changing the contents of the app.config file using a button...