开发者

c# default variables? Settings.Defaullt,defaultCity=txtcity.text; how to do them?

Well i downloaded a program for wheater but it is not mind now, i watched, than you write a city and you close the program, and when you open it again, it has de last city you write, how is it? i watched it has this code in whaterform_formClosed but how do i create these variables? and if this is posible can I to do a program without a database? saveing all in a dataset? or datatables? default databales? default dataset? but now i want to know how to create a Default variable

         private void weatherForm_FormClosed(object sender, FormClosedEventArgs e)
    {
        //Save Settings
        Settings.Default.defaultCity = txtCity.Text;
        Settings.Default.intervalText = comboBoxEdit1.Text;
        Settings.Default.windowPosition = this.Location;
        Settings.Default.timerOn = timer1.Enabled;
        Settings.Default.intervalTime = delay;
  开发者_如何学C      Settings.Default.Save();
    }


You can use 'settings' to do this:

Starting with the .NET Framework 2.0, you can create and access values that are persisted between application execution sessions. These values are called settings. Settings can represent user preferences, or valuable information the application needs to use. For example, you might create a series of settings that store user preferences for the color scheme of an application. Or you might store the connection string that specifies a database that your application uses. Settings allow you to both persist information that is critical to the application outside the code, and to create profiles that store the preferences of individual users.

See Using Application Settings and User Settings for more information.


The easiest way to store information like this is in the config file (like it is in your example)

If you open the properties of your project, it contains a tab called settings. Add the properties that you want in there, make sure they have a scope of User and you should be able to do something very similar.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜