ComponentResourceManager Class

Provides simple functionality for enumerating resources for a component or object. The ComponentResourceManager class is a ResourceManager.

System.Object
  System.Resources.ResourceManager
    System.ComponentModel.ComponentResourceManager

Namespace:  System.ComponentModel
Assembly:  System (in System.dll)

[HostProtectionAttribute(SecurityAction.LinkDemand, SharedState = true)]
public class ComponentResourceManager : ResourceManager

The ComponentResourceManager type exposes the following members.

  NameDescription
Public methodSupported by the XNA FrameworkComponentResourceManager()Initializes a new instance of the ComponentResourceManager class with default values.
Public methodSupported by the XNA FrameworkComponentResourceManager(Type)Creates a ComponentResourceManager that looks up resources in satellite assemblies based on information from the specified Type.
Top

  NameDescription
Public propertySupported by the XNA FrameworkBaseNameGets the root name of the resource files that the ResourceManager searches for resources. (Inherited from ResourceManager.)
Protected propertyFallbackLocationGets or sets the location from which to retrieve default fallback resources. (Inherited from ResourceManager.)
Public propertySupported by the XNA FrameworkIgnoreCaseGets or sets a value that indicates whether the resource manager allows case-insensitive resource lookups in the GetString and GetObject methods. (Inherited from ResourceManager.)
Public propertySupported by the XNA FrameworkResourceSetTypeGets the type of the resource set object that the resource manager uses to construct a ResourceSet object. (Inherited from ResourceManager.)
Top

  NameDescription
Public methodSupported by the XNA FrameworkApplyResources(Object, String)Applies a resource's value to the corresponding property of the object.
Public methodSupported by the XNA FrameworkApplyResources(Object, String, CultureInfo)Applies a resource's value to the corresponding property of the object.
Public methodSupported by the XNA FrameworkEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodSupported by the XNA FrameworkFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by the XNA FrameworkGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodSupported by the XNA FrameworkGetObject(String)Returns the value of the specified non-string resource. (Inherited from ResourceManager.)
Public methodSupported by the XNA FrameworkGetObject(String, CultureInfo)Gets the value of the specified non-string resource localized for the specified culture. (Inherited from ResourceManager.)
Protected methodSupported by the XNA FrameworkGetResourceFileNameGenerates the name of the resource file for the given CultureInfo object. (Inherited from ResourceManager.)
Public methodSupported by the XNA FrameworkGetResourceSetRetrieves the resource set for a particular culture. (Inherited from ResourceManager.)
Public methodGetStream(String)Returns an unmanaged memory stream object from the specified resource. (Inherited from ResourceManager.)
Public methodGetStream(String, CultureInfo)Returns an unmanaged memory stream object from the specified resource, using the specified culture. (Inherited from ResourceManager.)
Public methodSupported by the XNA FrameworkGetString(String)Returns the value of the specified string resource. (Inherited from ResourceManager.)
Public methodSupported by the XNA FrameworkGetString(String, CultureInfo)Returns the value of the string resource localized for the specified culture. (Inherited from ResourceManager.)
Public methodSupported by the XNA FrameworkGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by the XNA FrameworkInternalGetResourceSetProvides the implementation for finding a resource set. (Inherited from ResourceManager.)
Protected methodSupported by the XNA FrameworkMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by the XNA FrameworkReleaseAllResourcesTells the resource manager to call the Close method on all ResourceSet objects and release all resources. (Inherited from ResourceManager.)
Public methodSupported by the XNA FrameworkToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Protected fieldSupported by the XNA FrameworkBaseNameFieldSpecifies the root name of the resource files that the ResourceManager searches for resources. (Inherited from ResourceManager.)
Protected fieldSupported by the XNA FrameworkMainAssemblySpecifies the main assembly that contains the resources. (Inherited from ResourceManager.)
Protected fieldSupported by the XNA FrameworkResourceSets Obsolete. Contains a Hashtable that returns a mapping from cultures to ResourceSet objects. (Inherited from ResourceManager.)
Top

NoteNote

The HostProtectionAttribute attribute applied to this type or member has the following Resources property value: SharedState. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.

The following code example demonstrates how to use ComponentResourceManager to assign image resources to the Image property of ToolStripButton controls.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication10
{
    public class Form1 : Form
    {
        private ToolStripButton toolStripButton1;
        private ToolStripButton toolStripButton2;
        private ToolStripButton toolStripButton3;
        private ContextMenuStrip contextMenuStrip1;
        private IContainer components;
        private ToolStripMenuItem toolStripMenuItem1;
        private ToolStripMenuItem toolStripMenuItem2;
        private ContextMenuStrip contextMenuStrip2;
        private ToolStripMenuItem rearrangeButtonsToolStripMenuItem;
        private ToolStripMenuItem selectIconsToolStripMenuItem;
        private ToolStrip toolStrip1;

        public Form1()
        {
            InitializeComponent();
        }
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.Run(new Form1());
        }

        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.toolStrip1 = new System.Windows.Forms.ToolStrip();
            this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
            this.toolStripButton2 = new System.Windows.Forms.ToolStripButton();
            this.toolStripButton3 = new System.Windows.Forms.ToolStripButton();
            this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
            this.contextMenuStrip2 = new System.Windows.Forms.ContextMenuStrip(this.components);
            this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
            this.rearrangeButtonsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.selectIconsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStrip1.SuspendLayout();
            this.contextMenuStrip1.SuspendLayout();
            this.contextMenuStrip2.SuspendLayout();
            this.SuspendLayout();
            // 
            // Associate contextMenuStrip2 with toolStrip1. 
            // toolStrip1 property settings follow. 
            // 
            this.toolStrip1.ContextMenuStrip = this.contextMenuStrip2;
            this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.toolStripButton1,
            this.toolStripButton2,
            this.toolStripButton3});
            this.toolStrip1.Location = new System.Drawing.Point(0, 0);
            this.toolStrip1.Name = "toolStrip1";
            this.toolStrip1.Size = new System.Drawing.Size(292, 25);
            this.toolStrip1.TabIndex = 0;
            this.toolStrip1.Text = "toolStrip1";
            //  
            // toolStripButton1 
            //  
            this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image")));
            this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton1.Name = "toolStripButton1";
            this.toolStripButton1.Text = "toolStripButton1";
            //  
            // toolStripButton2 
            //  
            this.toolStripButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            this.toolStripButton2.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton2.Image")));
            this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton2.Name = "toolStripButton2";
            this.toolStripButton2.Text = "toolStripButton2";
            //  
            // toolStripButton3 
            //  
            this.toolStripButton3.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            this.toolStripButton3.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton3.Image")));
            this.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton3.Name = "toolStripButton3";
            this.toolStripButton3.Text = "toolStripButton3";
            //  
            // contextMenuStrip1 
            //  
            this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.toolStripMenuItem1,
            this.toolStripMenuItem2});
            this.contextMenuStrip1.Name = "contextMenuStrip1";
            this.contextMenuStrip1.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.contextMenuStrip1.Size = new System.Drawing.Size(131, 48);
            //  
            // contextMenuStrip2 
            //  
            this.contextMenuStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.rearrangeButtonsToolStripMenuItem,
            this.selectIconsToolStripMenuItem});
            this.contextMenuStrip2.Name = "contextMenuStrip2";
            this.contextMenuStrip2.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.contextMenuStrip2.Size = new System.Drawing.Size(162, 48);
            //  
            // toolStripMenuItem1 
            //  
            this.toolStripMenuItem1.Name = "toolStripMenuItem1";
            this.toolStripMenuItem1.Text = "&Resize";
            //  
            // toolStripMenuItem2 
            //  
            this.toolStripMenuItem2.Name = "toolStripMenuItem2";
            this.toolStripMenuItem2.Text = "&Keep on Top";
            //  
            // rearrangeButtonsToolStripMenuItem 
            //  
            this.rearrangeButtonsToolStripMenuItem.Name = "rearrangeButtonsToolStripMenuItem";
            this.rearrangeButtonsToolStripMenuItem.Text = "R&earrange Buttons";
            //  
            // selectIconsToolStripMenuItem 
            //  
            this.selectIconsToolStripMenuItem.Name = "selectIconsToolStripMenuItem";
            this.selectIconsToolStripMenuItem.Text = "&Select Icons";
            //  
            // Associate contextMenuStrip1 with Form1. 
            // Form1 property settings follow. 
            // 
            this.ClientSize = new System.Drawing.Size(292, 266);
            this.ContextMenuStrip = this.contextMenuStrip1;
            this.Controls.Add(this.toolStrip1);
            this.Name = "Form1";
            this.toolStrip1.ResumeLayout(false);
            this.contextMenuStrip1.ResumeLayout(false);
            this.contextMenuStrip2.ResumeLayout(false);
            this.ResumeLayout(false);
            this.PerformLayout();

        }
    }
}

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft