Aracılığıyla paylaş


How to: Add or Remove Application Settings

Application settings allow you to store and retrieve property settings and other information for your application dynamically. There are two types of application settings, based on scope: user-scoped and application-scoped settings.

At design time, you can add application settings either using the Settings pane of the Project Designer (Visual Basic and Visual C# only), or using the Properties window for a form or control, which allows you to bind a setting directly to a property.

To add application settings in the Project Designer

  1. Select a project in Solution Explorer; on the Project menu, click Properties.

  2. Select the Settings pane.

  3. Click a blank row in the Settings grid.

  4. Enter a name for the setting in the Name column. The name cannot contain spaces.

  5. Select a data type for the setting from the Type drop-down list.

  6. Select the scope of the setting from the Scope drop-down list. The setting's scope can be Application or User.

  7. Enter a default value for the setting in the Value column. The value must be appropriate for the selected data type.

To add application settings in the Properties window

  1. Select a form or control in the Form Designer; on the View menu, click Properties Window.

  2. In the Properties window, expand the (Application Settings) property (located under the Data node).

  3. Select the (Property Binding) property and click the ellipsis button (...) to open the Application Settings dialog box.

  4. In the Application Settings dialog box, select the property for which you wish to add an application setting.

  5. In the drop-down list for the property, click (New...) to open the New Application Setting dialog box.

  6. In the New Application Setting dialog box, select the Name property and enter a name for the setting. The name cannot contain spaces.

  7. Select the DefaultValue property and enter a default value for the setting.

  8. Select the scope of the setting from the Scope drop-down list. The setting's scope can be Application or User.

  9. To bind the new setting to the property, select it from the drop-down list, then click OK.

    The property binding will be added to the Properties window, and the new setting will be added to the Project Designer. Note that once you have created the setting, you must use the Project Designer to change it.

To remove application settings

  1. Select a project in Solution Explorer; on the Project menu, click Properties.

  2. Select the Settings pane.

  3. Click on the row in the Settings grid for the setting you wish to remove.

  4. Press the Delete key, or right-click and select Remove Setting.

    The setting will be removed from the Project Designer.

    Not

    You will need to remove settings manually from app.config because the Project Designer does not remove any references to application settings in your code or its own code.

See Also

Tasks

How to: Access Settings Events

Concepts

Application Settings

Accessing Application Settings (Visual Basic)

Other Resources

Managing Application Settings