Article Options
Recently Viewed
Premium Sponsor
Premium Sponsor

 »  Home  »  .NET Newbie  »  Simple Steps in VB.NET. Building a Custom Control
Simple Steps in VB.NET. Building a Custom Control
by Ged Mead | Published  05/14/2003 | .NET Newbie | Rating:
Ged Mead

Ged Mead (XTab) is a Microsoft Visual Basic MVP who has been working on computer software and design for more than 25 years. His journey has taken him through many different facets of IT. These include training as a Systems Analyst, working in a mainframe software development environment, creating financial management systems and a short time spent on military laptop systems in the days when it took two strong men to carry a 'mobile' system.

Based in an idyllic lochside location in the West of Scotland, he is currently involved in an ever-widening range of VB.NET, WPF and Silverlight development projects. Now working in a consultancy environment, his passion however still remains helping students and professional developers to take advantage of the ever increasing range of sophisticated tools available to them.

Ged is a regular contributor to forums on vbCity and authors articles for DevCity. He is a moderator on VBCity and the MSDN Tech Forums and spends a lot of time answering technical questions there and in several other VB forum sites. Senior Editor for DevCity.NET, vbCity Developer Community Leader and Admin, and DevCity.NET Newsletter Editor. He has written and continues to tutor a number of free online courses for VB.NET developers.

 

View all articles by Ged Mead...
Simple Steps in VB.NET. Building a Custom Control

Article source code: ssteps_customcontrol.zip

Introduction

This article is for beginners and demonstrates step by step how you can create a very basic custom control.

The control we are going to create is an enhanced version of a standard Button control which we will call the XtraButton control.

In this demo we are simply going to simply build on the functionality of an existing control, a Button control. There are much more sophisticated things that can be done, but as this is a 'Simple Steps' article, we'll stick to basics for now. We'll maybe get more adventurous in a later article.

Setting Up

First of all, open a new Project. Select the 'Windows Control Library' icon from the New Project - Templates Window.

Give the Project a meaningful name - "XtraButton" will do nicely.

Accept or overwrite the location for the files to be saved to.

Press OK. This will create a Solution which contains a Project named XtraButton, which in turn contains an object named UserControl1.vb.

Let's change the name of this user control to something more meaningful - "XtraButton" again.

Highlight the name 'UserControl1.vb' in the Solution Explorer and change it to XtraButton.vb.

We also need to rename the Class itself. So open the XtraButton.vb's code window and change the line which reads:

Public Class UserControl1

So that it reads:

Public Class XtraButton

As we are basing our new control totally on the standard button control, we can also change the code so that it specifically inherits all the properties, methods and events of a button.

Still in the Code Window, change the line that reads:

Inherits System.Windows.Forms.UserControl

So that it reads:

Inherits System.Windows.Forms.Button

Creating a Test Bed

Before we really begin to roll our sleeves up and create our nifty new control, we ought to have somewhere to test it out. It's often handy to be able to test it at various stages during it's creation, so we will deal with that requirement now.

In the Solution Explorer, select Solution 'XtraButton' and right-click it. From the drop-down menu, select Add... , then 'New Project'.

This time, make sure you select a 'Windows Application' template (it will probably still be highlighting the Windows Control Library template you selected previously). Give this new Windows Application project a meaningful name - 'Test Form', for instance.

I prefer to save the test projects in a subfolder of the Custom Control's own folder, so if you want to do that then use the Browse button to navigate your way there and then click OK to save it.

A quick check in the Solution Explorer will reassure you that all is as it should be - two projects are now displayed: XtraButton and Test Form.

Building the new Button

Turning our attention back to the user control itself now, by changing the code line so that the control inherits specifically from the Button control class and not from the more generic 'UserControl' we actually already have a User Control. However, it's not a very exciting one, because it simply replicates the standard button control at this stage.

But we'll continue to take this a small step at a time. In the Visual Studio menu, choose Build, then Build XtraButton. You're unlikely to get any errors showing in the Output Window (but if you do, I would suggest that you're sufficiently unlucky that you should avoid walking under ladders or going outside in lightning storms!)

(Don't forget to save your Solution at regular intervals.)

Just Checking

Another brief sidestep here to allow us to check that the Control does actually exist and that we can use it, if we wanted to.

Open the Design Window of Form1 in your Test Form Project (selectable from the Solution Explorer).

You've saved and Built the XTraButton. Now, in the Solution Explorer, select the Test Form project. Right Click on the project name and from the context menu that appears, select 'Add Reference'. A new dialog box entitled 'Add Reference' will then appear.

This dialog box has three tabs. Select the 'Projects' tab. It should contain only one entry - 'XtraButton' and its path information. Make sure this item is highlighted and click on the 'Select' button to the right of the dialog box. It will then appear in the lower pane. Select this entry to highlight it, then finally click the OK button down at the bottom of the dialog box to confirm and close it.

Now, open the Toolbox. The Windows Forms Tab will be open by default. Use the small down arrow on the Tab to scroll to the bottom of the list of available controls. And there at the bottom of the list you should find - voila ! - the XtraButton control.

If you find that this doesn't work - and it can be problematic sometimes - then the best procedure is this. Towards the end of this article, there is a paragraph which is titled "Using Your Control in Other Projects". Follow the instructions in that paragraph, but START FROM WHERE IT SAYS "Right Click on the ToolBox..." because you obviously don't want to have another project on the go just yet; you still have a bit of legwork to do here first! This will enable you to add the XtraButton to your toolbox.

Select the XtraButton from the ToolBox and put one instance of it on your form Double click the icon or left click to select and draw it on the form. (If you were a bit generous with the size of the drawing surface when you first created the User Control Project, double clicking might present with a larger than life button!)

For the avoidance of any confusion (as if!), I should point out that the XtraButton appears at the end of the ToolBox list by default. It just happens to be a coincidence that in the example above, it is the last item because it begins with a letter X. If we'd named it SmartButton it would still have been sitting there last in line.

Running Before You Can Walk

At this stage (if you're easily excited) you may be keen to try running the solution in the usual way by pressing F5 or clicking the little Start arrow at the top of the IDE. Go on, then, give it a go!

Disappointing, huh? This little problem arises because at the moment the UserControl project is the StartUp project for this Solution (you created it first, remember?) . User Control projects don't have a Sub Main and can't be executed (VS creates a DLL file for you, but we really don't need to get into that).

All you have to do is set the Test Form project as Startup project.

Here's the easy way to do this:

  1. Select the Test Form project in Solution Explorer
  2. Right click it
  3. Choose "Set as Startup Project"
Now try running it again and everything will be fine - not very exciting ... but fine!

If you're interested, you may also check out the Solution Explorer once again and if you look at the References for the Test Form project, you will see that XtraButton has been added.

Let's Get Coding

Let's get started with those additional properties now. What might be neat would be to add a couple of ways of highlighting the button. The first way we'll do this is have the button change color when the mouse passes or hovers over it. And of course, we'll also need to include the code to change it back to the original color when the mouse is no longer over the button. Depending on the color chosen this can give the impression that the button 'lights up' as the mouse passes over it.

We need to declare some variables to hold the values of the button's colors as they change.

Add this code to the XtraButton Class's code in the Code Window:

    Private mOldColor As Color  ' Original button color
    Private mMOColor As Color   ' Mouse Over color

We can now incorporate these private variables into a new Property - the MouseOverColor Property. OK, so it's a bit long as names go, but it is descriptive!

Here is the code to create that property:

    Property MouseOverColor() As Color
        Get
            MouseOverColor = mMOColor
        End Get
        Set(ByVal Value As Color)
            mMOColor = Value
        End Set
    End Property

Once the control has been built, this new property will appear in the Properties Window of any instance of the XtraButton control that is placed on a form. And just like other standard properties, it can be changed at designtime in the Properties Window or at runtime as a result of code and/or user actions.

OK, fine, but so far it won't actually do anything, will it? So let's address that right now.

We'll create a procedure that will be called automatically whenever the mouse enters the visible area of the button. Here is that code:

    Private Sub XB_MouseEnter(ByVal sender As Object_
        ByVal e As System.EventArgsHandles MyBase.MouseEnter

        mOldColor = MyBase.BackColor
        Me.BackColor = mMOColor

    End Sub

What happens here is that the first line of the code makes a note of the color which had been chosen as the BackColor property of the XtraButton. (Because the XtraButton inherits all the properties of a standard button, it will have a BackColor property, just like any ordinary button).

The second line of code then changes the backcolor of the XtraButton to whatever color has been chosen as the MouseOverColor.

Before we go on to test this code, we'll add another procedure that handles what happens to the XtraButton's Backcolor when the mouse leaves:

    Private Sub XB_MouseLeave(ByVal sender As Object_
        ByVal e As System.EventArgsHandles MyBase.MouseLeave
        Me.BackColor = mOldColor
    End Sub

All this does is returns the XtraButton to the color it was before the mouse entered it's space.

Checkpoint

This might be a good place to see if we're heading in the right direction, so Build the XtraButton again, then select Form1.vb[Design]. Select an XtraButton from the Toolbox and place it somewhere on the form.

Click on the instance of the button on your form and press F4 to see the Properties Window for the XtraButton if it isn't already in view. You will see that, in addition to the properties you would normally expect to see for a button, there is now one named MouseOverColor, which currently has a white rectangle at the side of it.

A left mouse click on this rectangle will bring you the standard color picker menu. Choose a color.

Now, run the project and move the mouse and then away from the XtraButton. If all has gone to plan, it should change color when the mouse is over it and revert back when the mouse leaves. Try experimenting with different MouseOverColors, as well as with the basic BackColor properties.

Also add two or three XtraButtons in a vertical line on the form and give them the same MouseOverColor. Run the project again and you will see how it can add a kind of dynamic effect as the mouse traverses across them.

Attributes

If anyone else is going to use your control, it would be useful for them to have a description of each new property in the Properties Window. To add such a description, we will need to make some small additions to the code.

Firstly, add this statement at the very top of the code listing in the XtraButton's code window:

Imports System.ComponentModel

This will enable you to include attributes such as Descriptions with your properties.

Now, amend the first part of the code block for the MouseOverColor Property so that it reads as follows

<Description("Gets/Sets the BackColor of Control when Mouse is over it")> _
Property MouseOverColor() as Color

Notice the final underscore in that first line; you'll get an error if you miss it out

You'll need to Build the Control once again, then you can check to see if it has worked by going back to the Test Form Project and clicking on an XtraButton.

Now when you view the properties in the Properties Window, you will see that description is included at the bottom.

Using Your Control in Other Projects

You probably won't want to go to the trouble of creating this control just for use in a single project, so we'll finish off by covering how you can get access to the control in new projects.

Save and close the current project. Open a new project; choosing Windows Application from the Templates.

If you scroll down the controls in the ToolBox now you will see that the XtraButton is not there. So, we will need to add it to the list now.

Right Click on the ToolBox. Select Customize Toolbox from the menu that appears. Choose the .Net Framework Tab.

Now, click on the Browse button and navigate your way to the folder where you saved your User Control. Open the bin Subfolder of the project. You will see the file XtraButton.dll in that folder.

Click on the Open button and the control will be added to the list of .Net Framework Components in front of you. It should have automatically have been checked, but if it hasn't then you can do this now.

Close the Customize Toolbox menu by clicking OK. If you review the ToolBox again you will see that the XtraButton has been added. You are now able to use this control in this (and any future) projects that you create or use.

Moving On

From this very basic example, you will see that you can make many changes to the functionality of this control. You could make the color of the text change when the mouse is over it, or increase the size of the button very slightly (reverting to it's normal size when the mouse leaves). Or you can change the button color when it is clicked or when the mouse is left to hover over it . Some of these have been included in the attached project, but I'm sure you can think of others that you might want to incorporate yourself.

Related devCity.NET articles:

How would you rate the quality of this article?
1 2 3 4 5
Poor Excellent
Tell us why you rated this way (optional):

Article Rating
The average rating is: No-one else has rated this article yet.

Article rating:4.54385964912283 out of 5
 171 people have rated this page
Article Score98044
Comments    Submit Comment

Comment #1  (Posted by George on 05/16/2003)

I didn't have a notion how to make my own user control. This article gives what beginners really need: the sense of success and comprehensible instruction. Especially beginners need more instruction and less coding - just the way it can be found here. Striking simplicity has proved superior to complicated coding knowledge. I do hope to see more of this kind.
 
Comment #2  (Posted by Gabriel on 05/29/2003)

Hi there,
In your example you showed us the use of the description attribute.
Why is it that it doesnt show in intellsense in vb.net but it does in c#?

Is it a vb.net bug?

thanks
gabriel
 
Comment #3  (Posted by Ged Mead on 05/29/2003)

Hi Gabriel,
I'm not quite sure what you mean when you say that Intellisense doesn't work in VB.Net.

Certainly when I just tested it out now, I started a new Property description by typing in an angle bracket "<" as the first character. Intellisense then show ed me a context menu of the Attributes available. Selecting Description from that menu then gave me the choice of the two versions available.

So, if that doesn't work for you, it would seem to be a specific problem you're having with you r system, rather than a global VB.Net problem.





 
Comment #4  (Posted by Karen on 06/06/2003)

I created the component according to steps specified in the acrticle. But when I tried opening a new prject to add this newly created control, I could not find the control in the .net framework Components list. What am I doing wrong?
 
Comment #5  (Posted by KenP on 06/21/2003)

Hi Ged,

This is a great example of how to create a custom control. I am a veteran vb6 programmer and I am learning .NET. I love it, it is everything that a programmer could ask for in a language suite. My question is as follows.

I have replicated the steps that you have in the example, but I am unable to get the new control to show up in the toolbox. I have even downloaded your code to see if I was doing some wrong in the code, but it matches. I know that I am missing something, but I am not sure what it is. It is probably something simple and I will kick myself for not finding it.

Here is where I am step by step.

1. created the Windows Control Library and named it XtraButton.
2. changed the name of the class to XtraButton
3. changed the inherits line to read Inherits System.Windows.Forms.Button
4. build the XtraButton control (no errors)
5. added the new windows application and named it Test Form
6. Set Test Form as the startup project

Now according to your example I should be able to open the form1.vb in design mode and goto the toolbox and the XtraButton control should be at the bottom of the list. The new control is not in the list anywhere. I even checked the other tabs in the toolbox. It is nowhere to be found. Have I missed something?

Thanks for your help

Ken
Lake Jackson, Texas


 
Comment #6  (Posted by Ged Mead on 06/21/2003)

Ken,
The confusion may well be all my fault. I think the demo user control may have been pre-existing at the time I wrote the article/created the demo sample solution and therefore I could see it in my ToolBox, which led me to believe (wrongly) that you would too. At least that's the only theory I can come up with at the moment.

Anyway, I think the answer may be to ignore the duff information in the paragraph headed "Just Checking". Instead jump down to the paragraph titled "Using Your Control in Other Projects". If you follow the steps in that paragraph, I think you will find that the User Control
will now be available in the Toolbox for the Test Form. (You may need to rebuild the solution first).

I've just tested this theory with a brand new control and it worked for me (but then again so did my original instructions, or so I thought!). So, give that a try and, if it still doesn't work, please do let me know and I will keep looking for the flaw.

Just like everyone else, I find it incredibly frustrating when you follow the instructions and things don't work as advertised (and I always assume that I've missed something, just as you have, Ken). So I really do apologise if I've put you to a lot of unnecessary aggravation or spoilt
anyone else's day with this oversight.

Once I'm sure I've got it cracked, I'll have the article edited for the benefit of future, more fortunate, readers.

Feel free to email me with any other specific problems with this article and/or the project.

Karen,
I think your problem is slightly different, ie. You want to access the control for use in another solution/project. If you want to zip up and email me your user control project, I'll see if I can successfully Build it and add it to my ToolBox.
 
Comment #7  (Posted by KenP on 06/22/2003)

Thanks Ged,

That worked great. I can now use the user control that was created just the article says. That is really cool. I know that I will use this all of the time. This is probably one of the coolest features of .NET. I am sure that I will find many others with a little help from articles like this one.

Thanks

Ken
 
Comment #8  (Posted by Gabriel on 07/08/2003)

I have just noticed that you replied to my qustion regarding attibutes and intellsense in vb.net

May be I was not clear

suppose i do the following
_
Public Sub AddItem(ByVal newItem As String)
Dim idx As Integer
If Not Me.Items.Contains(newItem) Then
idx = Me.Items.Add(newItem)
Else
idx = Me.Items.IndexOf(newItem)
End If
Me.SelectedIndex = idx
End Sub

now in my code as soon as i type listbox1.additem i should see a tooltip saying
"Adding a new Item to the ListBox"

my point was you will not see it in vb.net but you will see it in c# . you will only see the description in the property grid.
why?

thanks
Gabriel
 
Comment #9  (Posted by Frances on 07/24/2003)

Thanks. It is easy to follow and you can get the basic concept from that.
 
Comment #10  (Posted by Ken on 10/15/2003)

Hi Ged,

First of all, thanks for the article, neat and easy to understand.
As I develop further, I encounter another problem and hope that you can give me a hand.
I have a project with all the controls that built from custom controls. Everything seems fine at run time, but when I try to modify something on form at design time, it took long long time to load up. I have around 30 controls (custom controls) on form, but it took me more than a min to load up a design window. It seems to me that VB.Net execute the code at design time as well (I coded something on HandleCreated event). I just wonder is it normal to be that slow? Or there's some trick to solve.

Thanks.

Regards,
Ken
 
Comment #11  (Posted by Haz on 01/29/2004)

Cool tutorial on how to make a simple Control, just what i've been looking for.

*thrumbs up* keep up the good work.

Oh by the way, ive slightly modufied that bit of coding so that it also changes the ForeColor (or in other words, the text colour). So both the text and button colours change on mouse over, mouse press and mouse out.

Again, thanks... credit will be given where due.

Thanks again,
Haz
 
Comment #12  (Posted by Haz on 01/29/2004)

Cool tutorial on how to make a simple Control, just what i've been looking for.

*thrumbs up* keep up the good work.

Oh by the way, ive slightly modufied that bit of coding so that it also changes the ForeColor (or in other words, the text colour). So both the text and button colours change on mouse over, mouse press and mouse out.

Again, thanks... credit will be given where due.

Thanks again,
Haz
 
Comment #13  (Posted by Tom Wilson on 07/07/2004)

It's that easy is it? Try this. Inherit the ComboBox as a new control. In its New() function, add:

Me.Items.Add("Test")

Build the .DLL.

New Windows Application, drop the new control on the form and run.

The combo has *2* "Test" items in it. MASSIVE BUG. The sample application inherits the code from the custom control's New function and "Cannot be modified". New() "cannot contain 'overrides'". Therefore, writing pre-formatted custom controls in VB.Net is impossible. I can't stop smacking my forehead.

 
Comment #14  (Posted by himraj13 on 07/09/2004)

hi there!!!
i read your article its very systmaticly describe the creation of a custom control. it's very usefull to me to undestand the consept of the custom control.

thanks buddy!!!
 
Comment #15  (Posted by an unknown user on 12/29/2004)
Rating
I've been pulling my hair out trying to figure out how to create a custom control, in VB.NET. This article, and example code, answers all my questions, and allowed me to create a simple text-based control for a college class assignment. Thanks!
 
Comment #16  (Posted by an unknown user on 02/10/2005)
Rating
I can see that in the toolbox image in this article there is a nice picture for XtraButton. How do you change that image associated to the control? I allways get an ugly image in my controls and i want to change it.

Thanks for your article,
Bernardo Marques
 
Comment #17  (Posted by Bernardo Marques on 02/10/2005)
Rating
I would like to know how to change the little picture that it in the toolbox side by side with the custom control. In your article there is a nice picture for XtraButton, but i allways get an ugly picture for my controls. How can I change that?
Thanks a lot,

Bernardo Marques
from Portugal
 
Comment #18  (Posted by an unknown user on 02/20/2005)
Rating
Very nice and clear, just what i needed
 
Comment #19  (Posted by an unknown user on 04/04/2005)
Rating
Good articles.
 
Comment #20  (Posted by an unknown user on 04/27/2005)
Rating
Thanks, this helped me get started on making my own control. Now I have the confidence to extend it further.
 
Comment #21  (Posted by an unknown user on 05/06/2005)
Rating
It explain in details and accurately and vert easy to understand,very helpful to beginners.
 
Comment #22  (Posted by an unknown user on 05/06/2005)

How does one make components that sit in the bar under the form (like a timer)?
 
Comment #23  (Posted by MonkeySUCK on 05/17/2005)

I am a lamer but here is some code

Here is code for a vertical label

Imports system.Drawing.Text

Private Sub Label1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs)
Dim strText As String = "Top to Bottom"
Dim lbl1gfx As Graphics = e.Graphics
Dim fnt As Font = New Font("Verdana", 12, FontStyle.Regular)
Dim SF As New StringFormat
SF.FormatFlags = StringFormatFlags.DirectionVertical
lbl1gfx.Clear(Color.White)
lbl1gfx.TextRenderingHint = TextRenderingHint.AntiAlias
lbl1gfx.DrawString(strText, fnt, Brushes.Black, 12, 12, SF)

End Sub
 
Comment #24  (Posted by an unknown user on 05/17/2005)
Rating
I thought it was really great! but I was one of those unlucky indeviduals that got an error on the first build.
Comparing my code to that of the authors, I discovered my IDE created an extra line of code involving some Load function. Deleted that line, and contineued fron there. All went very well. I loved it! can't wait to show off my new controll at school. Thanks
 
Comment #25  (Posted by Sudipto on 05/25/2005)
Rating
Dear Mr Ged,
I am really happy with what you have shown in creating a custom control. However, I lacked one very essential information that I was searching for...
I want the MouseOverColor property to be set to a default color in the property window (say to Pink) instead of the white color whenever an instance of XtraButton is dropped on the code designer. I look forward for your reply.
Thanks for your great work.
 
Comment #26  (Posted by an unknown user on 06/16/2005)
Rating
Concise and very well written. Author chose a simple example so you don't get bogged down in too many details.
 
Comment #27  (Posted by abdelak on 07/21/2005)

thanks a lot for your help, but i still have a problem :
I can't use my dll's functions (it's a library class...)
please if you know how to use it ,tel me

 
Comment #28  (Posted by xisket on 08/04/2005)
Rating
Hi and thanks.
I just have 1 question: how can i create an 'about' dialog box which shows when i click in the (About) property of the control?
 
Comment #29  (Posted by Ged Mead on 08/04/2005)
Rating
Do you want the About form to display from the XtraButton example in the article, or from a custom control of your own that you have created/plan to create?
 
Comment #30  (Posted by Joe on 08/05/2005)
Rating
MonkeySUCK- nice little trick for vertical labels! Thanks!
 
Comment #31  (Posted by an unknown user on 09/01/2005)
Rating
The guy's approach is really matured and he is very concise and accurate. Demonstrates real indepth of the area.
congratulations
 
Comment #32  (Posted by an unknown user on 09/24/2005)
Rating
This rating might be a little dated since the article was published in 2003 (rating is in Sep. 2005). This is an excellent article, and I found it very useful. The small error - about the usercontrol appearing on the toolbox palette - can be easily remedied by looking up the end of the document. Few among the programmers are great programmers, but far fewer still are great communicators. This author is one of them. Great job, Mr. Mead. BTW, I do C#, not VB, but had no difficulty in recognizing that attributes are in square brackets in C#.
 
Comment #33  (Posted by an unknown user on 09/24/2005)
Rating
This rating might be a little dated since the article was published in 2003 (rating is in Sep. 2005). This is an excellent article, and I found it very useful. The small error - about the usercontrol appearing on the toolbox palette - can be easily remedied by looking up the end of the document. Few among the programmers are great programmers, but far fewer still are great communicators. This author is one of them. Great job, Mr. Mead. BTW, I do C#, not VB, but had no difficulty in recognizing that attributes are in square brackets in C#.
 
Comment #34  (Posted by an unknown user on 10/26/2005)
Rating
Clear, concise, and very well written.
 
Comment #35  (Posted by an unknown user on 10/26/2005)
Rating
Clear, concise, and very well written.
 
Comment #36  (Posted by an unknown user on 11/25/2005)
Rating
helped me a lot
 
Comment #37  (Posted by an unknown user on 11/25/2005)
Rating
helped me a lot
 
Comment #38  (Posted by an unknown user on 12/12/2005)
Rating
Good For Beginners.
 
Comment #39  (Posted by an unknown user on 01/17/2006)
Rating
Very cool and easily explained with no hi funda techy words .... simple steps are simply superb !!!
 
Comment #40  (Posted by suryanarayana.d on 01/31/2006)
Rating
good for learners
 
Comment #41  (Posted by Adam on 02/02/2006)
Rating
This tutorial is EXACTLY what I was looking for. I needed to quickly learn how to build my own control and this article showed me how. I followed the instructions and was able to have my own personal control running in under 5 minutes.
 
Comment #42  (Posted by an unknown user on 02/15/2006)
Rating
I remember doing this back in college, but couldnt remember exactly how, after half a day playing and looking at some other tutorials which didnt helo this is step by step easy to read.
PERFECT tutorial, no mucking around straight to the point. FANTASTIC
 
Comment #43  (Posted by an unknown user on 03/30/2006)
Rating
Just an awesome description for a beginner, very simple to understand
 
Comment #44  (Posted by an unknown user on 04/03/2006)
Rating
Sweet and to the point. I would like to know why the intellisense description for MouseOverColor doesn't show up in the code view though in VB.NET (it does display in the design view's property window).
 
Comment #45  (Posted by Murtala Mustapha on 04/06/2006)
Rating
hi,
you have a very good ways to the beginers heart, please keep up the good work.
I have a problem with datagridview, that is how to format the headings and how to make it move focus to next cell when pressing the enter key or when selecting with a mouse from a combobox cell.

thanks a lot
 
Comment #46  (Posted by an unknown user on 05/12/2006)
Rating
Descripton is very interesting and very much understandable
 
Comment #47  (Posted by an unknown user on 05/26/2006)
Rating
good
 
Comment #48  (Posted by an unknown user on 06/01/2006)
Rating
This article is very clear and complete for beginers like me. Its very well explained and very easy to understand even for non english speakers like me. Ali (France)
 
Comment #49  (Posted by an unknown user on 06/07/2006)
Rating
good shot to begin, i 'll start with it to do my own userctrl with listbox.... hope i'll could
 
Comment #50  (Posted by Pragatheeswaran on 06/22/2006)
Rating
Really Cool. Plz tell me how 2 create a custom control which has 2 different type of contorls such as a lable and TextBox
 
Comment #51  (Posted by an unknown user on 06/22/2006)
Rating
Good Article
 
Comment #52  (Posted by an unknown user on 07/11/2006)
Rating
I really understand the way it describe step by step
 
Comment #53  (Posted by an unknown user on 07/11/2006)
Rating
There should be more theory also included with this article
 
Comment #54  (Posted by an unknown user on 07/22/2006)
Rating
It explained Step by Step.Thanks
 
Comment #55  (Posted by an unknown user on 07/25/2006)
Rating
Wow
 
Comment #56  (Posted by an unknown user on 08/09/2006)
Rating
Great for beginners.
 
Comment #57  (Posted by an unknown user on 08/18/2006)
Rating
Very well explained
 
Comment #58  (Posted by an unknown user on 09/06/2006)
Rating
gr8 help: no errors at all
and it works exelent...
 
Comment #59  (Posted by an unknown user on 09/26/2006)
Rating
its very descriptive and easy to understand
 
Comment #60  (Posted by an unknown user on 10/13/2006)
Rating
good one but it is not very good example
 
Comment #61  (Posted by an unknown user on 10/19/2006)
Rating
Thank you. This was a very clear and concise explanation that leaves many other tutorials for dead. Top job.
 
Comment #62  (Posted by an unknown user on 11/09/2006)
Rating
nice nice
 
Comment #63  (Posted by an unknown user on 11/15/2006)
Rating
I'm a newby and it's incredible for me at this stage...Thanks for all from Spain man!!
ssjaviss@yahoo.es
 
Comment #64  (Posted by Ashish on 11/21/2006)
Rating
thankyou
 
Comment #65  (Posted by an unknown user on 12/01/2006)
Rating
nice artical

 
Comment #66  (Posted by an unknown user on 01/10/2007)
Rating
I have been searching for exactly how to add a description to the properties of my controls. This is the only sight that explicitly mentioned to add:
Imports System.ComponentModel

Perhaps obvious to some, but I am a little new to some elements of the .NET environment.

Thanks!
-Paul-
 
Comment #67  (Posted by an unknown user on 01/10/2007)
Rating
Poor example
 
Comment #68  (Posted by an unknown user on 01/10/2007)
Rating
very easy to underastand
 
Comment #69  (Posted by an unknown user on 01/31/2007)
Rating
Just what I needed!
 
Comment #70  (Posted by an unknown user on 02/20/2007)
Rating
The Notes very userful to me. How to Send and Receive parameters between two projects. It is Possible.
 
Comment #71  (Posted by an unknown user on 03/30/2007)
Rating
Nice article about the Custom Controls
 
Comment #72  (Posted by an unknown user on 04/09/2007)
Rating
Great example. Simple to follow (used VB2005).
 
Comment #73  (Posted by an unknown user on 04/15/2007)
Rating
it teaches about inheritance, setting propertes, creating and reusing dll in one simple example! thats wonderful!
 
Comment #74  (Posted by an unknown user on 04/27/2007)
Rating
i have read it and it become very helpful
 
Comment #75  (Posted by an unknown user on 05/21/2007)
Rating
Hi
it's very usefull to beginers
 
Comment #76  (Posted by an unknown user on 05/22/2007)
Rating
It was really nice article, one thing that i didn't find was how to add a icon(bitmap) to the control
 
Comment #77  (Posted by an unknown user on 07/31/2007)
Rating
clear, consise and above all the code works
 
Comment #78  (Posted by an unknown user on 08/16/2007)
Rating
Hi Gabriel
this is a good example , but i wish that you show examples that are more complexity ,and show to us how we can deal with its properties and events.
with my regards
 
Comment #79  (Posted by an unknown user on 09/02/2007)
Rating
Kept it to a very simple example. Thanks. I'm very new at VB.NET and find that I have to learn everything from scratch (or almost). Very frustrating since I could do pretty much anything from VB6. This example helps a lot since it demonstrates quite a few concepts
 
Comment #80  (Posted by an unknown user on 09/18/2007)
Rating
Hi Ged,

I have gone through this article its very nice.but i cant notice difference between the user control and custom control.By reading this article i came to know how to create the custom control.

ok thanks a lot,
seshu,India
 
Comment #81  (Posted by an unknown user on 10/24/2007)
Rating
I've always wanted to add my own functionality to my controls. Thanks a bunch !
 
Comment #82  (Posted by an unknown user on 10/30/2007)
Rating
this is good one.
AJAY KHATRI................
BE,M.Tech(CS)
 
Comment #83  (Posted by an unknown user on 11/27/2007)
Rating
Gracias.!!!
Me ayudo mucho este articulo, muy interesante.
Ged muy bueno realmente,

 
Comment #84  (Posted by an unknown user on 12/12/2007)
Rating
Very well covered basics..
 
Comment #85  (Posted by an unknown user on 01/04/2008)
Rating
this is excellent article to create a use r control accourding to our needs. pls provide the how to change shape size of the button.
 
Comment #86  (Posted by Ged Mead on 01/05/2008)
Rating
You can change the size either when you create the user control itself or via client code when you create individual instances. It has a width and height property.
Re the shape, that's a bigger proposition if you are thinking in terms of, say, making a round or diamond shape button. It can certainly be achieved, but reaquires some effort. Now in 2008 I would recommend using VB/VS2008 and creating a shaped button via WPF and a revised ControlTemplate. Much easier! I will be publishing a guide on how to do this soon.
 
Comment #87  (Posted by an unknown user on 02/15/2008)
Rating
hi this example is very funny. but i have some doubt this XtraBotton control we can show the label box or text box like this control (like ToolBox).

Prakash Thamizh
 
Comment #88  (Posted by Ged Mead on 02/15/2008)
Rating
I'm sorry Prakesh but I don't really understand your comment. Custom Controls can be added to the ToolBox just like the standard controls you mention.
 
Comment #89  (Posted by an unknown user on 03/04/2008)
Rating
In some parts it is dark, but in general it is a good article. Thanks.
 
Comment #90  (Posted by an unknown user on 06/23/2008)
Rating
useful instructions step by step
 
Comment #91  (Posted by an unknown user on 08/09/2008)
Rating
Hello sir,
Thanks sir..Actually I wants that type of Button and It is Excellent .dll for .Net.
 
Comment #92  (Posted by an unknown user on 08/25/2008)
Rating
the solution is ok but its come to true only when i convert vb.net to dll file
 
Comment #93  (Posted by Ged Mead on 08/25/2008)
Rating
I don't quite follow the last comment. By creating a Library you automatically create a DLL. Sometimes the control doesn't immediately appear in the Toolbox. Perhaps that's what you meant?
 
Comment #94  (Posted by an unknown user on 09/15/2008)
Rating
Excellent work

 
Comment #95  (Posted by Akshaya on 09/15/2008)
Rating
Excellent Work
Its very useful for beginers

 
Comment #96  (Posted by an unknown user on 09/30/2008)
Rating
This explains so much.I wish I had seen this article Months ago
 
Comment #97  (Posted by an unknown user on 09/30/2008)
Rating
Great Friend
By Mayur
 
Comment #98  (Posted by an unknown user on 10/01/2008)
Rating
I have just follow your guidance successful :)
 
Comment #99  (Posted by an unknown user on 05/12/2009)
Rating
very nice
 
Comment #100  (Posted by an unknown user on 09/24/2009)
Rating
I'm using VisualStudio 2008. When I typed Inherits System.Windows.Forms.Button, this line was under-lined. So it's not allowed. When I put my mouse over this line, I saw a message which proposed me to use System.Windows.Forms.UserControl. I can't continue. Could you tell me how to correct it, please?
 
Comment #101  (Posted by an unknown user on 10/29/2009)
Rating
it clearly understand me how to create a custom control in vb.net
 
Comment #102  (Posted by an unknown user on 12/05/2009)
Rating
When attempted in VB 2008 the code automatically generated by the designed created many errors. I deleted the designer generated code from my program and copied the section from your code sample designer generated region into it's place to get it to work. What gives? Did you need to update this posting to VB 2008? What has changed in the Automatically Generated Code Section?
 
Comment #103  (Posted by an unknown user on 05/19/2010)
Rating
This was a great article on VB.NET usercontrols. I have been looking for ages for instructions on how to make them. Thankyou!
 
Comment #104  (Posted by an unknown user on 02/01/2011)
Rating
Although this is an older article, it's as relevant today as it was in 2003. This is the FIRST description I've seen of creating custom controls that is clear, concise, and useful for us newbies. Many, many thanks!!
 
Sponsored Links