Reader Level:
Windows Forms

Arrange Application Setting in Windows Form Application

By Sudhakar Chaudhary on Jul 15 2012
Here I am demonstrating how to arrange application settings without a text file or database.
    • Like
    • Love It
    • Awesome
    • Interesting
    • It's Okay
    • Thumbs Down
  • 20.7k
  • 0

You can save and retrieve application settings like page background color, font style and so on.

Form Design:


  1. Change Background Color of form
  2. Change Background color of Textbox
  3. Save User ID
  4. Save Password


After designing the form go to the Project Properties.

In the settings tab define a name and the type of a variable, also the scope and provide a default value:

Aloes value can blank


You can also do this using the app setting:


Reading Setting

On form:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace corner
    public partial class Form1 : Form
        //decalre variable***************
        Color FormColor;
        Color TextBoxColor;
        string UserID;
        string Password;

        public Form1()
        private void Form1_Load(object sender, EventArgs e)
            //reading Setting*****************************************
            FormColor = corner.Properties.Settings.Default.FormBg;
            TextBoxColor = corner.Properties.Settings.Default.TextBg;
            UserID = corner.Properties.Settings.Default.UserID;
            Password = corner.Properties.Settings.Default.Password;

            //Applying Stting*****************************************
            this.BackColor = FormColor;
            textBox1.BackColor = TextBoxColor;
            textBox2.BackColor = TextBoxColor;
            textBox1.Text = UserID;
            textBox2.Text = Password;

Save Setting:

//Save Setting********************************************
corner.Properties.Settings.Default.FormBg = this.BackColor;