Export (0) Print
Expand All

ToolboxBitmapAttribute Constructor

.NET Framework 1.1

Overload List

Initializes a new ToolboxBitmapAttribute object with an image from a specified file.

[Visual Basic] Public Sub New(String)
[C#] public ToolboxBitmapAttribute(string);
[C++] public: ToolboxBitmapAttribute(String*);
[JScript] public function ToolboxBitmapAttribute(String);

Initializes a new ToolboxBitmapAttribute object based on a 16 x 16 bitmap that is embedded as a resource in a specified assembly.

[Visual Basic] Public Sub New(Type)
[C#] public ToolboxBitmapAttribute(Type);
[C++] public: ToolboxBitmapAttribute(Type*);
[JScript] public function ToolboxBitmapAttribute(Type);

Initializes a new ToolboxBitmapAttribute object based on a 16 by 16 bitmap that is embedded as a resource in a specified assembly.

[Visual Basic] Public Sub New(Type, String)
[C#] public ToolboxBitmapAttribute(Type, string);
[C++] public: ToolboxBitmapAttribute(Type*, String*);
[JScript] public function ToolboxBitmapAttribute(Type, String);

Example

[C#] The following code shows how to apply a ToolboxBitmapAttribute to a control. Notice that the control class, ControlA, is in the namespace NamespaceA. Assume that NamespaceA is in AssemblyA. Then, the ToolboxBitmapAttribute constructor shown in the code will search AssemblyA for a resource named NamespaceA.MyBitmap.bmp.

[C#] Note   This example shows how to use one of the overloaded versions of the ToolboxBitmapAttribute constructor. For other examples that might be available, see the individual overload topics.
[C#] 
namespace NamespaceA
{
   [ToolboxBitmap(typeof(ControlA), "MyBitmap.bmp")]
   public class ControlA : System.Windows.Forms.UserControl
   {
      ...
   }
   ...
}
        

[C#] When Microsoft Visual Studio .NET embeds an image file (say MyBitmap.bmp) in an assembly, it prepends the name of the default namespace to the name of the image file. Unless you specify otherwise, the default namespace is the name of the assembly. So in the previous example, the bitmap would get embedded as a resource named AssemblyA.MyBitmap.bmp. To get the correct resource name (MyNamespace.MyBitmap.bmp), you would have to change the default namespace from MyAssembly to MyNamespace. In Solution Explorer, right-click your project, and choose Properties. In the General section of Common Properties, enter the correct default namespace.

[Visual Basic, C++, JScript] No example is available for Visual Basic, C++, or JScript. To view a C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

ToolboxBitmapAttribute Class | ToolboxBitmapAttribute Members | System.Drawing Namespace

Show:
© 2014 Microsoft