ToolboxBitmapAttribute Classe
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Vous permet de spécifier une icône pour représenter un contrôle dans un conteneur, tel que le concepteur de formulaires Microsoft Visual Studio.
public ref class ToolboxBitmapAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Class)]
public class ToolboxBitmapAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class)>]
type ToolboxBitmapAttribute = class
inherit Attribute
Public Class ToolboxBitmapAttribute
Inherits Attribute
- Héritage
- Attributs
Exemples
L’exemple de code suivant montre comment utiliser la ToolboxBitmapAttribute classe pour définir stop.bmp comme icône de boîte à outils pour le StopSignControl. Cet exemple suppose l’existence d’une bitmap de 16 par 16 pixels nommée stop.bmp à c :\.
[ToolboxBitmap("c:\\stop.bmp")]
public ref class StopSignControl:
public System::Windows::Forms::UserControl
{
private:
Label^ label1;
private:
Button^ button1;
public:
StopSignControl() : UserControl()
{
this->label1 = gcnew System::Windows::Forms::Label();
this->button1 = gcnew System::Windows::Forms::Button();
this->label1->Font = gcnew System::Drawing::Font(
"Microsoft Sans Serif", 12.0F,
System::Drawing::FontStyle::Regular,
System::Drawing::GraphicsUnit::Point, ((Byte) 0));
this->label1->ForeColor = System::Drawing::Color::Red;
this->label1->Location = System::Drawing::Point(24, 56);
this->label1->Name = "Label1";
this->label1->TabIndex = 0;
this->label1->Text = "Stop!";
this->label1->TextAlign =
System::Drawing::ContentAlignment::MiddleCenter;
this->button1->Enabled = false;
this->button1->Location = System::Drawing::Point(56, 88);
this->button1->Name = "Button1";
this->button1->Size = System::Drawing::Size(40, 32);
this->button1->TabIndex = 1;
this->button1->Text = "stop";
this->Controls->Add(this->button1);
this->Controls->Add(this->label1);
this->Name = "StopSignControl";
this->MouseEnter +=
gcnew EventHandler(this,
&StopSignControl::StopSignControl_MouseEnter);
this->MouseLeave +=
gcnew EventHandler(this,
&StopSignControl::StopSignControl_MouseLeave);
}
private:
void StopSignControl_MouseEnter(Object^ sender,
EventArgs^ e)
{
label1->Text = label1->Text->ToUpper();
label1->Font = gcnew System::Drawing::Font(label1->Font->FontFamily,
14.0F, FontStyle::Bold);
button1->Enabled = true;
}
private:
void StopSignControl_MouseLeave(Object^ sender,
EventArgs^ e)
{
label1->Text = label1->Text->ToLower();
label1->Font = gcnew System::Drawing::Font(label1->Font->FontFamily,
12.0F, FontStyle::Regular);
button1->Enabled = false;
}
};
[System.Drawing.ToolboxBitmap("c:\\stop.bmp")]
public class StopSignControl:
System.Windows.Forms.UserControl
{
internal System.Windows.Forms.Label Label1;
internal System.Windows.Forms.Button Button1;
public StopSignControl() : base()
{
this.Label1 = new System.Windows.Forms.Label();
this.Button1 = new System.Windows.Forms.Button();
this.Label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.0F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) 0));
this.Label1.ForeColor = System.Drawing.Color.Red;
this.Label1.Location = new System.Drawing.Point(24, 56);
this.Label1.Name = "Label1";
this.Label1.TabIndex = 0;
this.Label1.Text = "Stop!";
this.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.Button1.Enabled = false;
this.Button1.Location = new System.Drawing.Point(56, 88);
this.Button1.Name = "Button1";
this.Button1.Size = new System.Drawing.Size(40, 32);
this.Button1.TabIndex = 1;
this.Button1.Text = "stop";
this.Controls.Add(this.Button1);
this.Controls.Add(this.Label1);
this.Name = "StopSignControl";
}
private void StopSignControl_MouseEnter(object sender, System.EventArgs e)
{
Label1.Text.ToUpper();
Label1.Font = new System.Drawing.Font(Label1.Font.FontFamily, 14.0F,
System.Drawing.FontStyle.Bold);
Button1.Enabled = true;
}
private void StopSignControl_MouseLeave(object sender, System.EventArgs e)
{
Label1.Text.ToLower();
Label1.Font = new System.Drawing.Font(Label1.Font.FontFamily, 12.0F,
System.Drawing.FontStyle.Regular);
Button1.Enabled = false;
}
}
<System.Drawing.ToolboxBitmap("c:\stop.bmp")> _
Public Class StopSignControl
Inherits System.Windows.Forms.UserControl
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
Public Sub New()
MyBase.New()
Me.Label1 = New System.Windows.Forms.Label
Me.Button1 = New System.Windows.Forms.Button
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", _
12.0F, System.Drawing.FontStyle.Regular, _
System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.ForeColor = System.Drawing.Color.Red
Me.Label1.Location = New System.Drawing.Point(24, 56)
Me.Label1.Name = "Label1"
Me.Label1.TabIndex = 0
Me.Label1.Text = "Stop!"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
Me.Button1.Enabled = False
Me.Button1.Location = New System.Drawing.Point(56, 88)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(40, 32)
Me.Button1.TabIndex = 1
Me.Button1.Text = "stop"
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Label1)
Me.Name = "StopSignControl"
End Sub
Private Sub StopSignControl_MouseEnter(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.MouseEnter
Label1.Text.ToUpper()
Label1.Font = New System.Drawing.Font(Label1.Font.FontFamily, _
14.0F, System.Drawing.FontStyle.Bold)
Button1.Enabled = True
End Sub
Private Sub StopSignControl_MouseLeave(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.MouseLeave
Label1.Text.ToLower()
Label1.Font = New System.Drawing.Font(Label1.Font.FontFamily, 12.0F, _
System.Drawing.FontStyle.Regular)
Button1.Enabled = False
End Sub
End Class
Remarques
Vous pouvez appliquer un ToolboxBitmapAttribute à un contrôle afin que les conteneurs, tels que Microsoft Visual Studio Concepteur de formulaires, puissent récupérer une icône qui représente le contrôle. La bitmap de l’icône peut se trouver dans un fichier lui-même ou incorporé dans l’assembly qui contient le contrôle. La taille de la bitmap que vous incorporez dans l’assembly du contrôle (ou stocker dans un fichier distinct) doit être de 16 à 16. La GetImage méthode d’un ToolboxBitmapAttribute objet peut renvoyer la petite image 16 par 16 ou une grande image de 32 par 32 qu’elle crée en mettant à l’échelle la petite image.
Si vous souhaitez utiliser différentes versions de vos icônes avec différentes versions de votre assembly, vous n’avez pas besoin de modifier la ToolboxBitmapAttribute version pour chaque version. Au lieu de cela, vous pouvez déclarer l’assembly avec un BitmapSuffixInSameAssemblyAttribute ou un BitmapSuffixInSatelliteAssemblyAttribute, et spécifier une BitmapSuffix valeur de configuration pour chaque version d’assembly. Dans ce cas, un nom de fichier indiqué par un ToolboxBitmapAttribute est interprété avec le suffixe bitmap ajouté.
Constructeurs
| Nom | Description |
|---|---|
| ToolboxBitmapAttribute(String) |
Initialise un nouvel ToolboxBitmapAttribute objet avec une image à partir d’un fichier spécifié. |
| ToolboxBitmapAttribute(Type, String) |
Initialise un nouvel ToolboxBitmapAttribute objet basé sur une bitmap 16 par 16 incorporée en tant que ressource dans un assembly spécifié. |
| ToolboxBitmapAttribute(Type) |
Initialise un nouvel ToolboxBitmapAttribute objet basé sur une bitmap 16 x 16 incorporée en tant que ressource dans un assembly spécifié. |
Champs
| Nom | Description |
|---|---|
| Default |
Objet ToolboxBitmapAttribute qui a sa petite image et son image volumineuse définie sur |
Propriétés
| Nom | Description |
|---|---|
| TypeId |
En cas d’implémentation dans une classe dérivée, obtient un identificateur unique pour cette Attribute. (Hérité de Attribute) |
Méthodes
| Nom | Description |
|---|---|
| Equals(Object) |
Indique si l’objet spécifié est un ToolboxBitmapAttribute objet et est identique à cet ToolboxBitmapAttribute objet. |
| GetHashCode() |
Obtient un code de hachage pour cet ToolboxBitmapAttribute objet. |
| GetImage(Object, Boolean) |
Obtient la petite ou la grande Image associée à cet ToolboxBitmapAttribute objet. |
| GetImage(Object) |
Obtient la petite Image associée à cet ToolboxBitmapAttribute objet. |
| GetImage(Type, Boolean) |
Obtient la petite ou la grande Image associée à cet ToolboxBitmapAttribute objet. |
| GetImage(Type, String, Boolean) |
Obtient la petite ou la grande Image associée à cet ToolboxBitmapAttribute objet. |
| GetImage(Type) |
Obtient la petite Image associée à cet ToolboxBitmapAttribute objet. |
| GetImageFromResource(Type, String, Boolean) |
Retourne un Image objet basé sur une ressource bitmap incorporée dans un assembly. |
| GetType() |
Obtient la Type de l’instance actuelle. (Hérité de Object) |
| IsDefaultAttribute() |
En cas de substitution dans une classe dérivée, indique si la valeur de cette instance est la valeur par défaut de la classe dérivée. (Hérité de Attribute) |
| Match(Object) |
En cas de substitution dans une classe dérivée, retourne une valeur qui indique si cette instance est égale à un objet spécifié. (Hérité de Attribute) |
| MemberwiseClone() |
Crée une copie superficielle du Objectactuel. (Hérité de Object) |
| ToString() |
Retourne une chaîne qui représente l’objet actuel. (Hérité de Object) |
Implémentations d’interfaces explicites
| Nom | Description |
|---|---|
| _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
Mappe un jeu de noms avec un jeu correspondant d'identificateurs de dispatch. (Hérité de Attribute) |
| _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
Récupère les informations de type d’un objet, qui peuvent être utilisées pour obtenir les informations de type d’une interface. (Hérité de Attribute) |
| _Attribute.GetTypeInfoCount(UInt32) |
Récupère le nombre d'interfaces d'informations de type fourni par un objet (0 ou 1). (Hérité de Attribute) |
| _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
Fournit l’accès aux propriétés et méthodes exposées par un objet. (Hérité de Attribute) |