Solved

c# setting.settings

Posted on 2006-11-24
4
947 Views
Last Modified: 2008-01-09
I have enter a test value for color.

this is what I did.

 public Form1()
        {
            InitializeComponent();
            this.BackColor = Properties.Settings.Default.myColor;
        }


 private void button1_Click(object sender, EventArgs e)
        {
            colorDialog1.ShowDialog();
            Properties.Settings.Default.myColor = colorDialog1.Color;
            Properties.Settings.Default.Save();
        }

when I close the application and rerun it the color that was picked is correct. However when I look at the setting.settings the color still shows the default color which I pick at first which was blue.

I have 2 questions:
1. where does the setting for the new color get saved at?
I looked at the exe.config and I see the blue color that I picked in the setup of the application. I do not see the new color that is coming up.

2. what does the synchronize button do when pressed. Everything I press it I get a messagebox that states :

No user.config files were found in any of the following locations:

0
Comment
Question by:bman9111
  • 3
4 Comments
 
LVL 20

Accepted Solution

by:
REA_ANDREW earned 500 total points
ID: 18011296
this works for me, and persists the color when the app is shutdown and restarted

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            panel1.BackColor = Settings1.Default.MyColor;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ColorDialog nc = new ColorDialog();
            if (nc.ShowDialog() == DialogResult.OK)
            {
                this.button1.BackColor = nc.Color;
                Settings1.Default.MyColor = nc.Color;
                Settings1.Default.Save();
                panel1.BackColor = Settings1.Default.MyColor;
            }
        }
    }
0
 
LVL 8

Author Comment

by:bman9111
ID: 18014932
thank you, however I know how to set that. my question is these:

I have 2 questions:
1. where does the setting for the new color get saved at?
I looked at the exe.config and I see the blue color that I picked in the setup of the application. I do not see the new color that is coming up.

2. what does the synchronize button do when pressed. Everything I press it I get a messagebox that states :


I do appreciate the coding though.
0
 
LVL 8

Author Comment

by:bman9111
ID: 18088791
any ideas?
0
 
LVL 8

Author Comment

by:bman9111
ID: 18163478
u there?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now