I checked this information on the Internet. Someone used to rewrite or copy settings. designer. CS method to make it work, we know that this file is automatically generated by the system, so it is best not to do this.
Here is a simple and practical method. This method can change the value set in the application range at runtime, but cannot be saved! To save this example, a user-defined setting is provided. You can also use other methods. This method can also be applied to encryption, which is useful for database connection strings :).
Here is an example for illustration:
1. Create a window ApplicationProgram
2. Place a textbox and button on the form.
3. Add two configuration items in Solution Explorer. As follows:
Username application range
Username2 user range
4. Add a form load event and a button click event.
5,CodeAs follows:
Namespace Setting
{
Public Partial Class Form1: Form
{
Public Form1 ()
{
Initializecomponent ();
}
Private Void Form1_load ( Object Sender, eventargs E)
{
Setting. properties. settings. Default [ " Username " ] = Setting. properties. settings. Default. username2;
Textbox1.text = Setting. properties. settings. Default. Username;
}
private void button#click ( Object sender, eventargs e)
{< br> setting. properties. settings. default. username2 = textbox1.text;
setting. properties. settings. default. save ();
}< BR >}