Icon for Components

  • Thread starter Thread starter OpticTygre
  • Start date Start date
O

OpticTygre

When you create a new component, compile it, and add it to the toolbox, it
comes with that boring gearbox icon next to it. How can you change the icon
associated with a new component you create?
 
Imports System.ComponentModel

<ToolboxBitmap("C:\MyPic.bmp")> _
Public Class MyClass
....
End Class

Obviously, the bitmap file is the path to your bitmat for the toolbox icon.

I hope this helps
 
OpticTygre said:
When you create a new component, compile it, and add it to the toolbox, it
comes with that boring gearbox icon next to it. How can you change the
icon associated with a new component you create?

Create a bitmap of size 16 × 16 and give it the name of the class ('Class
BlaBla' ->
"BlaBla.bmp"). Then you can add the bitmap to the project and set its build
action to embedded resource. Extend your code like this:

\\\
<ToolboxBitmap(GetType(BlaBla))>
Public Class BlaBla
 
Hmm...instead of referring to a static place on the drive, can I integrate
it into the DLL I create? Like, if I add the bitmap or icon to my project,
can I refer to it that way, rather than on the drive of the computer?
 
Ahhh, thanks. That's exactly what I was looking for. Just learning about
attributes, too, so this is another one that gets added to the list.
 
Herfried, not sure what you mean by create a bitmap and give it the name of a
Class. I know how to create bitmaps using the image editor and add them add
them as embeded resources but don't understand how to give them the name of a
class. Could you please explain a bit more...thanks.
 
Dennis said:
Herfried, not sure what you mean by create a bitmap and give it the name
of a
Class. I know how to create bitmaps using the image editor and add them
add
them as embeded resources but don't understand how to give them the name
of a
class. Could you please explain a bit more...thanks.

The name of the bitmap file must consist of the class' name with ".bmp"
appended to the end (class 'Foo', name of bitmap file "Foo.bmp").
 
I think I understand now. I create a bitmap and name it Foo.bmp then add it
to my UserControl project as an embedded resource. Then it will
automatically show up in the ToolBox opposite the UserControl Class Name if I
use the ToolBoxBitmap Attribute.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top