views:

266

answers:

2

How do you create your own custom component for vb.net 2008? I want it to simply output to a .dll, not a whole winforms app.

So, here is what I have done so far:

  1. Made a class library project
  2. Added a custom control object
  3. Confused myself badly
  4. Googled it, to no avail

How can I control the component? For example, I want my component to not have a visible design view, I want it to stay below like the stopwatch component and the notifyicon component and such, it is not something to be designed. Then, how do I edit the possible properties a user can control, and make them effect the end result? What do I place the code which powers the component on? The class library file, or something else?

Thanks for your help! I have a whole set of components I am going to create, this will get me going much faster than trial and error.

A: 

OK... This is a really abbreviated example. You should start by basing yous off of an existing .net component.

Public Class MyControl
 Inherits DataGridView

'...add your properties/functionality...'

End Class

Then compile the DLL, and add it as a reference to whatever project you are working on. Once added, you can add the controls in the DLL into your toolbox.

This has more instructions on how to modify a UserControl (slightly different from the one above, but it explains well. This is a general explanation.

@comments - Yes, there, are things that will do what you want. Start with a class that inherits Form instead of DataGridView in the example I gave you, and the changes described in the links provided.

"Your properties and functionality" is whatever you want to do that the base control does not do.

StingyJack
Any way to start from scratch? I *really* do not want to copy any functionality from any of them, as mine is nothing like those D:
Cyclone
Start small, understand how it works. Then take on the larger pieces. I find it very doubtful that there is not a control already available that doesnt serve part of your needs.
StingyJack
Actually, trust me, there isn't. At all..... Anyway, how do I "add my properties/functionality"? By properties, do you mean subs and functions? Can you give a better example?
Cyclone
+2  A: 

I think you may want to check some walkthrough on how to create components. Such as this one: Walkthrough: Authoring a Component with Visual Basic. Once you are done with that one, there are more walkthroughs on various related topics, such as how to use design-time support, implementing designers and so on.

Fredrik Mörk
Thats for vb.net 2005 D:
Cyclone
Believe me, the difference between VB2005 and VB2008 is really not that big.
Fredrik Mörk
...anyway, updated the links to point to the VB2008 versions of the articles.
Fredrik Mörk
Kk, thanks! Ill take a look through them.
Cyclone
I fail to see the "new" class as described in the walkthrough...
Cyclone
*public sub new
Cyclone
Public Sub New() is the default constructor. Its always there unless you declare other constructors.
StingyJack