Customized component as timer

  • Thread starter Thread starter Alcibiade
  • Start date Start date
A

Alcibiade

Hello to all, I'd like to create a customized component that has not a
window( for example as timer, background worker and so on) and that shows in
the property window only few properties and few events.
How could I create it?
Thanks
 
Alcibiade said:
Hello to all, I'd like to create a customized component that has not a
window( for example as timer, background worker and so on) and that shows in
the property window only few properties and few events.
How could I create it?
Thanks

I believe there are at least two ways to do this.

1) Add new item to your project selecting "Component Class" as the object type

2) add a new regular class to your project and have it inherit from
System.ComponentModel.Component.

Mike
 
Hello to all, I'd like to create a customized component that has not a
window( for example as timer, background worker and so on) and that shows in
the property window only few properties and few events.
How could I create it?
Thanks

The basic idea is create a windows forms control library, and add a new
component class - this is simply a class that inherits from Component. You
then basically define your properties/methods/events as you would any other
class. You can further customize your classes designer behavior using various
attributes (for instance, you can set your components toolbox icon using the
ToolboxBitmap attribute) and by creating custom property editors...

For a simple component example, you can look here (C# code though, sorry):
http://tom-shelton.net/index.php/2009/10/07/creating-a-simple-hotkey-component-using-registerhotkey/
 
Tom Shelton said:
The basic idea is create a windows forms control library, and add a new
component class - this is simply a class that inherits from Component.
You
then basically define your properties/methods/events as you would any
other
class. You can further customize your classes designer behavior using
various
attributes (for instance, you can set your components toolbox icon using
the
ToolboxBitmap attribute) and by creating custom property editors...

For a simple component example, you can look here (C# code though, sorry):
http://tom-shelton.net/index.php/2009/10/07/creating-a-simple-hotkey-component-using-registerhotkey/

thanks to all
I 've created the component inheriting bycomponentModel.component

Now I have a stupid problem, but I'm not able to solve it:
how can I set the icon?
I've tried
<Drawing.ToolboxBitmap

but I don't know how can I use it.

I ve seen some examples on :

http://www.bobpowell.net/toolboxbitmap.htm

http://www.bluevisionsoftware.com/WebSite/TipsAndTricksDetails.aspx?Name=ToolboxBitmapAttribute

but without success....

Can anyone tell me it or a simple working project so I can discover alone?

Thanks in advance
 
thanks to all
I 've created the component inheriting bycomponentModel.component

Now I have a stupid problem, but I'm not able to solve it:
how can I set the icon?
I've tried
<Drawing.ToolboxBitmap

but I don't know how can I use it.

I ve seen some examples on :

http://www.bobpowell.net/toolboxbitmap.htm

http://www.bluevisionsoftware.com/WebSite/TipsAndTricksDetails.aspx?Name=ToolboxBitmapAttribute

but without success....

Can anyone tell me it or a simple working project so I can discover alone?

Thanks in advance

Actually, the one I pointed you to does work - as I assume those do as well.
BUT... You have to add the compiled dll to your toolbox. So, if you download
the example from my website, you will have two projects one for the component
dll, and one that contains a C# usage example and an equivalent VB.NET
example. To make the bitmap work, you have to compile the component dll - and
then add that to your toolbox. You should then see the icon in the toolbox.
You should then be able to drag and drop the component on a form, and see the
bitmap.

Are you setting your bmp image as an embedded resource?

My example, translated to VB would look something like:

<ToolboxBitmap (GetType(Hotkey), "ToolboxImage.bmp") > _
Public Partial Class Hotkey
Inherits Component
....
End Class

ToolboxImage.bmp is a project item, with it's Build Action set to Embedded
Resource.

HTH
 
Tom Shelton said:
ToolboxImage.bmp is a project item, with it's Build Action set to Embedded
Resource.

HTH


I used a 32x32 image and it didn't work.
With 16x16 image it works ;)

I'd have 2 questions more...

When I add my component to toolbox, it s put in "general section". How could
I change the section? For example add it to "common controls" section?

How can I add a description to my component so when the user move the mouse
upon it, he can read what it does?
Thanks again
 
Back
Top