Alex Gordon
Alex Gordon

Reputation: 60731

application settings not saving

unfortunately my settings do not get saved. please help

If ColorDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
    Form1.BackColor = ColorDialog1.Color
    My.Settings.mytext = My.Settings.mytext & Str(Abs(ColorDialog1.Color.ToArgb)) & ", "

End If

onload i load the settings back into the textbox

Upvotes: 0

Views: 3210

Answers (3)

jay_t55
jay_t55

Reputation: 11652

Each and every time you set a setting, you need to remember to Save that setting otherwise there's really no point in setting it in the first place...

Example:

// edit a setting. My.Setting.MyName = "Jason";

// Now, save it. My.Setting.Save();

:-)

Upvotes: 1

Kevin LaBranche
Kevin LaBranche

Reputation: 21078

I did your above code in a windows form and it worked just fine. Are you sure it's not changing? I had a text box set to the value on form load and it did change even though in the app.config it didn't change at all.

EDIT:

Since these are user settings, they are saved in a user.config for the user's profile in local settings\application data folder.

Upvotes: 1

Joel Coehoorn
Joel Coehoorn

Reputation: 415735

You have to call My.Settings.Save()

Upvotes: 2

Related Questions