Share via


How to: Add or Remove Resources

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.

Note

The procedures for adding and removing string resources differ from those of the other resource types. For more information, see How to: Add or Remove String Resources.

Note

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?" Clicking Yes will give the new resource strongly-typed resource support, a compile-time feature that encapsulates access to resources by creating classes that contain a set of static read-only (get) properties. 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 Managing Application Resources.

To add an existing resource

  1. With a project selected in Solution Explorer, on the Project menu, click Properties.

  2. Select the Resources tab.

  3. On the Resource Designer toolbar, point to Add Resource, click the arrow, and then click Add Existing File.

  4. 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.

  5. For file resources, you can optionally set the Encoding and FileType properties for the file in the Properties window.

To add a new resource

  1. With a project selected in Solution Explorer, on the Project menu, click Properties.

  2. Select the Resources tab.

  3. On the Resource Designer toolbar, point to Add Resource, click the arrow, and then click the type of resource you want to create.

  4. 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.

  5. For file resources, you can optionally set the Encoding and FileType properties for the file in the Properties window.

To remove a resource

  1. With a project selected in Solution Explorer, on the Project menu, click Properties.

  2. Select the Resources tab.

  3. Select a resource type from the Categories list.

  4. Select the resource that you want to remove.

  5. 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.

See Also

Tasks

How to: Edit Resources

How to: Add or Remove String Resources

How to: Edit String Resources

Reference

My.Resources Object

Concepts

Accessing Application Resources (Visual Basic)

Accessing Application Resources (Visual Basic)

Other Resources

Managing Application Resources

Resources Page, Project Designer