Como: Adicionar ou remover recursos
You can use the Resource Designer to add or edit resources for your project. Resource types supported by the Resource Designer include strings, images, icons, audio, and files.
Observação |
---|
The procedures for adding and removing string resources differ from those of the other resource types. For more information, see Como: Adicionar ou remover recursos de seqüência de caracteres. |
Observação |
---|
When you add a new image to a project, the Resource Editor does not add a reference to System.Drawing, which is necessary for compilation. You have to add that reference by using Solution Explorer. |
In addition to the tasks in the following list, you can add resources by dragging them to the Resource Designer. When dropped, the resource is added to the appropriate resource category based on its file name extension.
If you add a resource manually to the project (for example, by adding a .resx file in 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 suporte de recurso fortemente tipado, um recurso de tempo de compilação que encapsula o acesso aos recursos criando classes que contêm um conjunto de propriedades de somente leitura estático (get). This provides the preferred way to consume resources, instead of using the GetString and GetObject methods of the ResourceManager class. For more information, see StronglyTypedResourceBuilder.
For information about how the Resource Designer generates strongly-typed resources, see Gerenciando Recursos de Aplicativo.
To add an existing resource
With a project selected in Solution Explorer, on the Project menu, click Properties.
Select the Resources tab.
On the Resource Designer toolbar, point to Add Resource, click the arrow, and then click Add Existing File.
In the Add existing file to resources dialog box, browse to the file that contains the resource that you want to add (.bmp, .ico, .wav, etc,), and then click Open.
The file will be added to the Resources directory, and the Resource Designer will open the Category pane for the resource type that you added.
For file resources, you can optionally set the Encoding and FileType properties for the file in the Properties window.
To add a new resource
With a project selected in Solution Explorer, on the Project menu, click Properties.
Select the Resources tab.
On the Resource Designer toolbar, point to Add Resource, click the arrow, and then click the type of resource you want to create.
In the Add new resource dialog box, enter a name for the new resource, and then click Add.
The file will be added to the Resources directory, and a resource editor will open for the resource type that you added.
For file resources, you can optionally set the Encoding and FileType properties for the file in the Properties window.
To remove a resource
With a project selected in Solution Explorer, on the Project menu, click Properties.
Select the Resources tab.
Select a resource type from the Categories list.
Select the resource that you want to remove.
On the Resource Designer toolbar, click Remove Resource.
The resource will be removed from the Resource Designer, but it will not be removed from the Resources directory.
Consulte também
Tarefas
Como: Adicionar ou remover recursos de seqüência de caracteres
Como: Editar recursos de seqüência de caracteres
Referência
Objeto My.Resources (Visual Basic)
Página de recursos, Designer de projeto
Conceitos
Acessando recursos de aplicativo (Visual Basic)
Acessando recursos de aplicativo (Visual Basic)