Resources Object


Resources Object

Location

My.Resources

Description

Use the My.Resources object to access the global culture-specific resources for the active application. Resources are initially managed in Visual Studio using the new Resources panel of the project's Properties window. (Access this window by double-clicking on the "My Project" item in the Solution Explorer or by selecting Properties from Visual Studio's Project menu.) This form lets you add resources to a project, including named strings, images, icons, and other file-based resources. You can also add file-based resources to the project as standard items in the Solution Explorer.

All added resources are defined through the project's Resources.resx (or similar) resource file. To support the features required by My.Resources, Visual Studio also creates a separate Resources.Designer.vb file. This file includes standard Visual Basic source code that provides property-based retrieval of resources from the project's resource file.

As resources are added to a project, they are dynamically added as properties in the My.Resources object. For example, if you add a string resource named ConfirmDataDelete, it can be accessed in your code as:

 My.Resources.ConfirmDataDelete 

and it will be strongly typed as a String. For those resources added as file items to the project, the resource is referenced as:

 My.Resources.resourceFile.resourceName 

All resource properties available through My.Resources are read-only.

My.Resources uses the resources associated with the My.Application.CurrentUICulture culture, although you can override this default and use a different culture.

Public Members

Each resource added to your project becomes a property in the My.Resources object. In addition to these, there are two members used to manage access to the resources.

Member

Description

Culture

Property. Allows you to override the default culture used for resource retrieval. Assigned culture objects of type System.Globalization.CultureInfo.

ResourceManager

Property. Provides access to an object of type System.Resources.ResourceManager that provides more traditional .NET access to resources.


Usage at a Glance

Only application-wide resources are accessible through My.Resources; form-level resources (often used for culture-specific labels) are not available through this object.

Related Framework Entries

  • System.Resources.ResourceManager

See Also

Forms Object, My Namespace, ChangeUICulture Method, Settings Object, UICulture Property, WebServices Object




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net