Share via


Como: Adicionar ou remover configurações do aplicativo

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: configurações de escopo do usuário e o escopo do aplicativo.

Em tempo de design, você pode adicionar configurações de aplicativo através da configurações o painel da Project Designer (Visual Basic e Visual C# apenas), ou usando o Propriedades janela para um formulário ou controle, que permite você vincular uma configuração diretamente a uma propriedade.

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. Selecione um projeto em Solution Explorer; sobre o projeto menu, clique em Propriedades.

  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.

    ObservaçãoObservação

    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.

Consulte também

Tarefas

Como: Eventos de configuração de acesso

Conceitos

Configurações de aplicativo

Acessando as configurações do aplicativo (Visual Basic)

Outros recursos

Gerenciando definições de aplicativo