Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ToolboxBitmap
Message
From
18/06/2008 00:41:52
 
 
To
17/06/2008 05:54:23
General information
Forum:
ASP.NET
Category:
Other
Title:
Environment versions
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01324632
Message ID:
01325022
Views:
12
I haven't used this attribute yet, but I'm planning to. If you use the overload of the attribute that you showed:
[ToolboxBitmap(typeof(myControl), "myBitmap.bmp")
you don't have to retrieve the embedded resource (but you *do* need to imbed the .bmp in the resource to begin with). In your example, this would be an image imbedded into the project that contains the class "myControl".

You could also use .NET's images for certain controls as well. For example, suppose I have my own TextBox subclass. If add this to the ToolBox, as is, I get the same default image, which looks like a gear-shape. If I want the image to look like the regular image for a TextBox, then I use the attribute this way:
[ToolboxBitmap(typeof(System.Windows.Forms.TextBox)]
public class MyTextBox : System.Windows.Forms.TextBox
{
}
Here's what the documentation has to say about the constructor for your original example:


Constructor
public ToolboxBitmapAttribute (Type t, string name)

Remarks
This constructor searches for an embedded resource in the assembly that defines the type specified by the t parameter. The constructor searches for a resource named namespace.name, where namespace is the namespace containing the definition of the class specified by the t parameter. For example, suppose that ControlA is a class in NamespaceA in AssemblyA.dll and that you passed "MyBitmap.bmp" to the name parameter. Then the constructor searches AssemblyA.dll for a resource named NamespaceA.MyBitmap.bmp.

Example
'The following code example demonstrates how to use the ToolboxBitmapAttribute constructor to set StopSignControl2.bmp as a toolbox icon for the StopSignControl2. This example assumes the existence of a 16-by-16-pixel bitmap named StopSignControl2.bmp with its BuildAction property set to EmbeddedResource.


~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Reply
Map
View

Click here to load this message in the networking platform