Custom Controls

  • Thread starter Thread starter Ryan Joseph So
  • Start date Start date
R

Ryan Joseph So

Hi how can I change the icon of a custom control when viewed in the
toolbox? Thanks
 
Set the ToolboxBitmap attribute, by specifying the type of the control,
and a bitmap for it.

[ToolboxBitmap(typeof(xxx), "path to image")]

You might want to check out this MSDN Help link too:
ms-help://MS.VSCC/MS.MSDNVS/vbcon/html/vbtskProvidingToolboxBitmapForYou
rControl.htm

HTH,
fbhcah
 
With attributes.

[ToolboxBitmap(typeof(Button))]
class MyControl1 : UserControl
{
}
// Specifies a bitmap file.
[ToolboxBitmap(@"C:\Documents and Settings\Joe\MyPics\myImage.bmp")]
class MyControl2 : UserControl
{
}
// Specifies a type that indicates the assembly to search, and the name
// of an image resource to look for.
[ToolboxBitmap(typeof(MyControl), "MyControlBitmap")]
class MyControl : UserControl
{
}


Cheers,
Branimir

Branimir Giurov
MCSD.NET, MCDBA, MCT
eAgility LLC
 
Ryan,

You could also adding a 16*16 256color bmp file with the
same name as the control (except for the extensions) will do
the trick. Otherwize just add it to your project as an embedded
resource and use the following

[ToolboxBitmap(typeof(MyControl), "NameOfBitmap")]
class MyControl : UserControl
{
}

HTH,

//Andreas
 
Thank you very much for that quick reply, it really helps a lot. I just
have one more favor to ask, what books or web site can you recommend for
me that contains lots of stuff about creating custom controls using C#.
 
Back
Top