Compartilhar via


Como: Adicionar ou remover recursos de seqüência de caracteres

You can use the Resource Designer to add or edit string resources for your project. The procedures for adding and removing string resources differ from those of other resource types. For information about how to manage non-string resource types, see Como: Adicionar ou remover recursos.

We do not recommend that you use string resources for large strings, because they are hard to edit, and there is a limit of 32767 characters. Instead, add a text file by using Add New Text File from the Add Resource list in the Resource Designer. The new text file will be added to the Resources directory. It can contain as much text as you want, and you can set the encoding if you need to. However, when you compile the program, it will appear as if it had been entered in the string table.

If you add a string resource manually to the project (for example, by adding a .resx file using Solution Explorer), the resources in the new file will be separate from the resources that you create by using the Resource page of the Project Designer. If you double-click the new .resx file, a separate Resource Designer window will open, displaying the file's contents in a settings grid. When you add the new .resx file, you will be prompted with a message asking, "Do you want to enable strongly typed resource generation for this file?" Clicando em Sim fornecerá o novo recurso fortemente tipado suporte de recurso, um tempo de compilação que encapsula o acesso aos recursos criando classes que contêm um conjunto de propriedades somente leitura estático (get). This provides an alternative way to consume resources, instead of using the GetString and GetObject methods of the ResourceManager class. For more information, see StronglyTypedResourceBuilder.

You can also add string resources by using drag-and-drop editing with the Resource Designer. When you drag and drop strings, the Name, Value, and Comment fields must be separated by tab stops or the whole string will be added to the Name column.

For information about how the Resource Designer generates strongly-typed resources, see Gerenciando Recursos de Aplicativo.

To add a string resource

  1. Com um projeto selecionado no Solution Explorerdiante do projeto menu, clique em Propriedades.

  2. Click the Resources tab. On the Resource Designer toolbar, point to the resource view drop-down, click the arrow, and make sure that it is set to Strings (which is the default). A settings grid will appear, displaying the strings maintained by that instance of the Resource Designer.

  3. Click the Name column of the last row in the grid, which is marked with an asterisk (*).

  4. In the Name column, enter a name for the string.

  5. In the Value column, enter the string that you want to use as a resource.

    ObservaçãoObservação

    To include line breaks (CLRF characters) in your string, type Shift + Enter. You will have to resize the row to be able to see all the lines in your string. Position the pointer on the bottom border of the row in the leftmost column of the grid, and then click and drag the border down to resize.

  6. Optionally, enter a comment in the Comment column.

    ObservaçãoObservação

    Comments are not compiled into the application; they are available only at design time.

To remove a string resource

  1. Com um projeto selecionado no Solution Explorerdiante do projeto menu, clique em Propriedades.

  2. Click the Resources tab.

  3. On the Resource Designer toolbar, point to the resource view drop-down, click the arrow, and make sure that it is set to Strings (which is the default).

  4. Select the row that contains the string you want to remove by clicking in the gray row header.

  5. On the Resource Designer toolbar, click Remove Resource.

Consulte também

Tarefas

Como: Editar recursos de seqüência de caracteres

Como: Adicionar ou remover recursos

Como: Editar recursos

Referência

Objeto My.Resources (Visual Basic)

Página de recursos, Designer de projeto

Conceitos

Acessando recursos de aplicativo (Visual Basic)

Outros recursos

Gerenciando Recursos de Aplicativo