ComponentResourceManager Konstruktory
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Inicializuje novou instanci ComponentResourceManager třídy.
Přetížení
| Name | Description |
|---|---|
| ComponentResourceManager() |
Inicializuje novou instanci ComponentResourceManager třídy s výchozími hodnotami. |
| ComponentResourceManager(Type) |
Vytvoří ComponentResourceManager , která vyhledá prostředky v satelitních sestaveních na základě informací ze zadaného Type. |
ComponentResourceManager()
Inicializuje novou instanci ComponentResourceManager třídy s výchozími hodnotami.
public:
ComponentResourceManager();
public ComponentResourceManager();
Public Sub New ()
Platí pro
ComponentResourceManager(Type)
Vytvoří ComponentResourceManager , která vyhledá prostředky v satelitních sestaveních na základě informací ze zadaného Type.
public:
ComponentResourceManager(Type ^ t);
public ComponentResourceManager(Type t);
new System.ComponentModel.ComponentResourceManager : Type -> System.ComponentModel.ComponentResourceManager
Public Sub New (t As Type)
Parametry
- t
- Type
A Type , ze kterého se ComponentResourceManager odvozují všechny informace pro vyhledání souborů prostředků.
Příklady
Následující příklad kódu ukazuje použití ComponentResourceManager k přiřazení prostředků obrázku Image k vlastnosti ovládacích ToolStripButton prvků.
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsApplication10;
public class Form1 : Form
{
ToolStripButton toolStripButton1;
ToolStripButton toolStripButton2;
ToolStripButton toolStripButton3;
ContextMenuStrip contextMenuStrip1;
IContainer components;
ToolStripMenuItem toolStripMenuItem1;
ToolStripMenuItem toolStripMenuItem2;
ContextMenuStrip contextMenuStrip2;
ToolStripMenuItem rearrangeButtonsToolStripMenuItem;
ToolStripMenuItem selectIconsToolStripMenuItem;
ToolStrip toolStrip1;
public Form1() => InitializeComponent();
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form1());
}
void InitializeComponent()
{
components = new Container();
ComponentResourceManager resources = new(typeof(Form1));
toolStrip1 = new ToolStrip();
toolStripButton1 = new ToolStripButton();
toolStripButton2 = new ToolStripButton();
toolStripButton3 = new ToolStripButton();
contextMenuStrip1 = new ContextMenuStrip(components);
contextMenuStrip2 = new ContextMenuStrip(components);
toolStripMenuItem1 = new ToolStripMenuItem();
toolStripMenuItem2 = new ToolStripMenuItem();
rearrangeButtonsToolStripMenuItem = new ToolStripMenuItem();
selectIconsToolStripMenuItem = new ToolStripMenuItem();
toolStrip1.SuspendLayout();
contextMenuStrip1.SuspendLayout();
contextMenuStrip2.SuspendLayout();
SuspendLayout();
//
// Associate contextMenuStrip2 with toolStrip1.
// toolStrip1 property settings follow.
//
toolStrip1.ContextMenuStrip = contextMenuStrip2;
toolStrip1.Items.AddRange(
[
toolStripButton1,
toolStripButton2,
toolStripButton3
]);
toolStrip1.Location = new Point(0, 0);
toolStrip1.Name = "toolStrip1";
toolStrip1.Size = new Size(292, 25);
toolStrip1.TabIndex = 0;
toolStrip1.Text = "toolStrip1";
//
// toolStripButton1
//
toolStripButton1.DisplayStyle = ToolStripItemDisplayStyle.Image;
toolStripButton1.Image = (Image)resources.GetObject("toolStripButton1.Image");
toolStripButton1.ImageTransparentColor = Color.Magenta;
toolStripButton1.Name = "toolStripButton1";
toolStripButton1.Text = "toolStripButton1";
//
// toolStripButton2
//
toolStripButton2.DisplayStyle = ToolStripItemDisplayStyle.Image;
toolStripButton2.Image = (Image)resources.GetObject("toolStripButton2.Image");
toolStripButton2.ImageTransparentColor = Color.Magenta;
toolStripButton2.Name = "toolStripButton2";
toolStripButton2.Text = "toolStripButton2";
//
// toolStripButton3
//
toolStripButton3.DisplayStyle = ToolStripItemDisplayStyle.Image;
toolStripButton3.Image = (Image)resources.GetObject("toolStripButton3.Image");
toolStripButton3.ImageTransparentColor = Color.Magenta;
toolStripButton3.Name = "toolStripButton3";
toolStripButton3.Text = "toolStripButton3";
//
// contextMenuStrip1
//
contextMenuStrip1.Items.AddRange([
toolStripMenuItem1,
toolStripMenuItem2]);
contextMenuStrip1.Name = "contextMenuStrip1";
contextMenuStrip1.RightToLeft = RightToLeft.No;
contextMenuStrip1.Size = new Size(131, 48);
//
// contextMenuStrip2
//
contextMenuStrip2.Items.AddRange([
rearrangeButtonsToolStripMenuItem,
selectIconsToolStripMenuItem]);
contextMenuStrip2.Name = "contextMenuStrip2";
contextMenuStrip2.RightToLeft = RightToLeft.No;
contextMenuStrip2.Size = new Size(162, 48);
//
// toolStripMenuItem1
//
toolStripMenuItem1.Name = "toolStripMenuItem1";
toolStripMenuItem1.Text = "&Resize";
//
// toolStripMenuItem2
//
toolStripMenuItem2.Name = "toolStripMenuItem2";
toolStripMenuItem2.Text = "&Keep on Top";
//
// rearrangeButtonsToolStripMenuItem
//
rearrangeButtonsToolStripMenuItem.Name = "rearrangeButtonsToolStripMenuItem";
rearrangeButtonsToolStripMenuItem.Text = "R&earrange Buttons";
//
// selectIconsToolStripMenuItem
//
selectIconsToolStripMenuItem.Name = "selectIconsToolStripMenuItem";
selectIconsToolStripMenuItem.Text = "&Select Icons";
//
// Associate contextMenuStrip1 with Form1.
// Form1 property settings follow.
//
ClientSize = new Size(292, 266);
ContextMenuStrip = contextMenuStrip1;
Controls.Add(toolStrip1);
Name = "Form1";
toolStrip1.ResumeLayout(false);
contextMenuStrip1.ResumeLayout(false);
contextMenuStrip2.ResumeLayout(false);
ResumeLayout(false);
PerformLayout();
}
}
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Public Class Form1
Inherits Form
Private toolStripButton1 As ToolStripButton
Private toolStripButton2 As ToolStripButton
Private toolStripButton3 As ToolStripButton
Private contextMenuStrip1 As ContextMenuStrip
Private components As IContainer
Private toolStripMenuItem1 As ToolStripMenuItem
Private toolStripMenuItem2 As ToolStripMenuItem
Private contextMenuStrip2 As ContextMenuStrip
Private rearrangeButtonsToolStripMenuItem As ToolStripMenuItem
Private selectIconsToolStripMenuItem As ToolStripMenuItem
Private toolStrip1 As ToolStrip
Public Sub New()
InitializeComponent()
End Sub
<STAThread()> _
Public Sub Main()
Application.EnableVisualStyles()
Application.Run(New Form1())
End Sub
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Dim resources As New System.ComponentModel.ComponentResourceManager(GetType(Form1))
Me.toolStrip1 = New System.Windows.Forms.ToolStrip()
Me.toolStripButton1 = New System.Windows.Forms.ToolStripButton()
Me.toolStripButton2 = New System.Windows.Forms.ToolStripButton()
Me.toolStripButton3 = New System.Windows.Forms.ToolStripButton()
Me.contextMenuStrip1 = New System.Windows.Forms.ContextMenuStrip(Me.components)
Me.contextMenuStrip2 = New System.Windows.Forms.ContextMenuStrip(Me.components)
Me.toolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem()
Me.toolStripMenuItem2 = New System.Windows.Forms.ToolStripMenuItem()
Me.rearrangeButtonsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.selectIconsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.toolStrip1.SuspendLayout()
Me.contextMenuStrip1.SuspendLayout()
Me.contextMenuStrip2.SuspendLayout()
Me.SuspendLayout()
'
' Associate contextMenuStrip2 with toolStrip1.
' toolStrip1 property settings follow.
'
Me.toolStrip1.ContextMenuStrip = Me.contextMenuStrip2
Me.toolStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.toolStripButton1, Me.toolStripButton2, Me.toolStripButton3})
Me.toolStrip1.Location = New System.Drawing.Point(0, 0)
Me.toolStrip1.Name = "toolStrip1"
Me.toolStrip1.Size = New System.Drawing.Size(292, 25)
Me.toolStrip1.TabIndex = 0
Me.toolStrip1.Text = "toolStrip1"
'
' toolStripButton1
'
Me.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
Me.toolStripButton1.Image = CType(resources.GetObject("toolStripButton1.Image"), System.Drawing.Image)
Me.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta
Me.toolStripButton1.Name = "toolStripButton1"
Me.toolStripButton1.Text = "toolStripButton1"
'
' toolStripButton2
'
Me.toolStripButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
Me.toolStripButton2.Image = CType(resources.GetObject("toolStripButton2.Image"), System.Drawing.Image)
Me.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta
Me.toolStripButton2.Name = "toolStripButton2"
Me.toolStripButton2.Text = "toolStripButton2"
'
' toolStripButton3
'
Me.toolStripButton3.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
Me.toolStripButton3.Image = CType(resources.GetObject("toolStripButton3.Image"), System.Drawing.Image)
Me.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta
Me.toolStripButton3.Name = "toolStripButton3"
Me.toolStripButton3.Text = "toolStripButton3"
'
' contextMenuStrip1
'
Me.contextMenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.toolStripMenuItem1, Me.toolStripMenuItem2})
Me.contextMenuStrip1.Name = "contextMenuStrip1"
Me.contextMenuStrip1.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.contextMenuStrip1.Size = New System.Drawing.Size(131, 48)
'
' contextMenuStrip2
'
Me.contextMenuStrip2.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.rearrangeButtonsToolStripMenuItem, Me.selectIconsToolStripMenuItem})
Me.contextMenuStrip2.Name = "contextMenuStrip2"
Me.contextMenuStrip2.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.contextMenuStrip2.Size = New System.Drawing.Size(162, 48)
'
' toolStripMenuItem1
'
Me.toolStripMenuItem1.Name = "toolStripMenuItem1"
Me.toolStripMenuItem1.Text = "&Resize"
'
' toolStripMenuItem2
'
Me.toolStripMenuItem2.Name = "toolStripMenuItem2"
Me.toolStripMenuItem2.Text = "&Keep on Top"
'
' rearrangeButtonsToolStripMenuItem
'
Me.rearrangeButtonsToolStripMenuItem.Name = "rearrangeButtonsToolStripMenuItem"
Me.rearrangeButtonsToolStripMenuItem.Text = "R&earrange Buttons"
'
' selectIconsToolStripMenuItem
'
Me.selectIconsToolStripMenuItem.Name = "selectIconsToolStripMenuItem"
Me.selectIconsToolStripMenuItem.Text = "&Select Icons"
'
' Associate contextMenuStrip1 with Form1.
' Form1 property settings follow.
'
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.ContextMenuStrip = Me.contextMenuStrip1
Me.Controls.Add(toolStrip1)
Me.Name = "Form1"
Me.toolStrip1.ResumeLayout(False)
Me.contextMenuStrip1.ResumeLayout(False)
Me.contextMenuStrip2.ResumeLayout(False)
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub