ToolboxBitmapAttribute Class
Allows you to specify an icon to represent a control in a container, such as the Microsoft Visual Studio Form Designer.
Assembly: System.Drawing (in System.Drawing.dll)
The ToolboxBitmapAttribute type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | ToolboxBitmapAttribute(String) | Initializes a new ToolboxBitmapAttribute object with an image from a specified file. |
![]() | ToolboxBitmapAttribute(Type) | Initializes a new ToolboxBitmapAttribute object based on a 16 x 16 bitmap that is embedded as a resource in a specified assembly. |
![]() | ToolboxBitmapAttribute(Type, String) | Initializes a new ToolboxBitmapAttribute object based on a 16 by 16 bitmap that is embedded as a resource in a specified assembly. |
| Name | Description | |
|---|---|---|
![]() | Equals | Indicates whether the specified object is a ToolboxBitmapAttribute object and is identical to this ToolboxBitmapAttribute object. (Overrides Attribute::Equals(Object).) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Gets a hash code for this ToolboxBitmapAttribute object. (Overrides Attribute::GetHashCode().) |
![]() | GetImage(Object) | Gets the small Image associated with this ToolboxBitmapAttribute object. |
![]() | GetImage(Type) | Gets the small Image associated with this ToolboxBitmapAttribute object. |
![]() | GetImage(Object, Boolean) | Gets the small or large Image associated with this ToolboxBitmapAttribute object. |
![]() | GetImage(Type, Boolean) | Gets the small or large Image associated with this ToolboxBitmapAttribute object. |
![]() | GetImage(Type, String, Boolean) | Gets the small or large Image associated with this ToolboxBitmapAttribute object. |
![]() ![]() | GetImageFromResource | Returns an Image object based on a bitmap resource that is embedded in an assembly. |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute.) |
![]() | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
| Name | Description | |
|---|---|---|
![]() ![]() | _Attribute::GetIDsOfNames | Maps a set of names to a corresponding set of dispatch identifiers. (Inherited from Attribute.) |
![]() ![]() | _Attribute::GetTypeInfo | Retrieves the type information for an object, which can be used to get the type information for an interface. (Inherited from Attribute.) |
![]() ![]() | _Attribute::GetTypeInfoCount | Retrieves the number of type information interfaces that an object provides (either 0 or 1). (Inherited from Attribute.) |
![]() ![]() | _Attribute::Invoke | Provides access to properties and methods exposed by an object. (Inherited from Attribute.) |
You can apply a ToolboxBitmapAttribute to a control so that containers, such as Microsoft Visual Studio Form Designer, can retrieve an icon that represents the control. The bitmap for the icon can be in a file by itself or embedded in the assembly that contains the control. The size of the bitmap that you embed in the control's assembly (or store in a separate file) should be 16 by 16. The GetImage method of a ToolboxBitmapAttribute object can return the small 16 by 16 image or a large 32 by 32 image that it creates by scaling the small image.
The following code example demonstrates how to use the ToolboxBitmapAttribute class to set stop.bmp as the toolbox icon for the StopSignControl. This example assumes the existence of a 16-by-16-pixel bitmap named stop.bmp at 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; } };
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
