I am creating a custom web server control in a Web Control library within Visual Studio, and I would like to use a custom icon with it. I have created a bitmap for the icon with the library and given it the same name as the custom control. I have also set
the Build Action property of the bitmap to Embedded Resource. When I build the project, though, the default gear icon is used. Is there something else I need to do to use the custom icon?
All of the components in the MyControls assembly use the default gear icon, because we never set specific icons on each control. Setting an icon is as easy as adjusting the icon property on the control class.
I was reading a blog about 3 weeks ago, Where theres a flag in the compiler where you add where your icon is and It is automatically put in for you. I'll try finding it.
I'm programming in VB, so typeof isn't available. I tried using GetType instead, but then the control didn't appear in the Toolbox at all. But thanks for the suggestion.
Give it the same name as the class of your custom control (ie : yourControl.bmp)
Place it in the same directory, and then make it an embedded resource of your assembly.
To enable the bitmap as an embedded resource, right-click the bitmap file and select the Properties menu item. From the Properties page, set the Build Action to Embedded Resource.
So when you will place your control in a page, the Toolbox will search the assembly manifest for an embedded bitmap with the same qualified name as the control, here is the reason why the bitmap must have the same name as the
class of your control.
(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)
AnneB
Member
36 Points
20 Posts
Icon for custom server control
Dec 02, 2005 07:38 PM|LINK
Blake05
Contributor
2561 Points
511 Posts
Re: Icon for custom server control
Dec 03, 2005 01:20 AM|LINK
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/custwebcon.asp
All of the components in the MyControls assembly use the default gear icon, because we never set specific icons on each control. Setting an icon is as easy as adjusting the icon property on the control class.
Blog - Website: windowscoding.com
AnneB
Member
36 Points
20 Posts
Re: Icon for custom server control
Dec 05, 2005 06:38 PM|LINK
Blake,
I have already read the article you pointed me to, but I don't see an icon property for the control class. Where do I set this property?
Anne
namio
Member
125 Points
25 Posts
Re: Icon for custom server control
Dec 06, 2005 11:06 AM|LINK
I also read the refered topic, and saw nothing about set an icon for a control.
Luis Abreu
All-Star
25674 Points
5369 Posts
MVP
Re: Icon for custom server control
Dec 06, 2005 11:56 AM|LINK
hello.
if i'm not mistaken, you have 2 options:
1.) name the bitmap such that it has the same name as the control
2.) use the toolboxbitmapattribute
Regards,
Luis Abreu
email: labreu_at_gmail.com
EN blog:http://msmvps.com/blogs/luisabreu
AnneB
Member
36 Points
20 Posts
Re: Icon for custom server control
Dec 06, 2005 08:15 PM|LINK
I have tried both of these techniques and neither seems to work.
Anne
Pluginbaby
Contributor
2961 Points
486 Posts
MVP
Re: Icon for custom server control
Dec 07, 2005 05:57 PM|LINK
Hello Anne,
Let me say if this work for you !
Laurent Duveau
MVP / MCT / RD
http://weblogs.asp.net/lduveau/
Blake05
Contributor
2561 Points
511 Posts
Re: Icon for custom server control
Dec 07, 2005 09:15 PM|LINK
Blog - Website: windowscoding.com
AnneB
Member
36 Points
20 Posts
Re: Icon for custom server control
Dec 09, 2005 05:53 PM|LINK
Pluginbaby
Contributor
2961 Points
486 Posts
MVP
Re: Icon for custom server control
Dec 12, 2005 10:48 AM|LINK
Ok, so just forget the toolbox attribute...
Verify your bitmap has the following properties :
Height of 16 pix
Width of 16 pix
16 colors
Give it the same name as the class of your custom control (ie : yourControl.bmp)
Place it in the same directory, and then make it an embedded resource of your assembly.
To enable the bitmap as an embedded resource, right-click the bitmap file and select the Properties menu item. From the Properties page, set the Build Action to Embedded Resource.
So when you will place your control in a page, the Toolbox will search the assembly manifest for an embedded bitmap with the same qualified name as the control, here is the reason why the bitmap must have the same name as the class of your control.
Laurent Duveau
MVP / MCT / RD
http://weblogs.asp.net/lduveau/