How to create and use User Controls in VB.NET

How to create and use User Controls in VB.NET


Check out the website: http://www.mkasoft.com for more tutorials and how to.
Closed Caption:

ok hello guys in this video we are going
to see how you can create your own user
control and how you can put that inside
the DML and ported to other applications
so before we start the control that
we're going to create is going to
display a message letter by letter
ok it will be like a label but you know
what few other features
ok so here we go so first thing we have
this project you if you check the
solution here you'll find your project
available right click your project
select from the list of options active
control
ok and here you are required to enter
the name of the control and here we are
going to call it letter by letter home
label ok that's it
and now we are going to say at that's it
so what you see right here is actually
the control and this control doesn't
contain anything okay this is just spat
ground
ok now what are we gonna do is
placing enable control on it
ok so here this is the label control now
we are going to change this behavior a
little bit so i'm going to double-click
this one now in the low the event label
sorry they will one . left 40 label
sorry one . top equals zero on the label
one . with equally . word and label
wondered hide equal me . height now they
mean he represent the control itself to
think about it you can think of the
controls about it's more like a windows
form
okay that can be embedded inside another
form in other words the same way that
you put a label here okay you can put a
label hair on modify its behavior you
can do the same thing with the control
and this is what are we doing right here
so we just changed changed education and
sighs and I'm going to go to the resize
okay what happens when we resize this
control we are going to repeat the same
coat
ok
go now this is the basic behavior now
what do you want to display here we need
to specify number of things we want to
know what message to display so this
message is going to be the property in
this case so now let's say private
user message as string ok and am setting
this as a private because I don't want
anyone to have direct access into this
property now the way I want others to
access this one is through a property so
this is how you define it public
property text string
ok the moment you create the property
called text or any other name you will
have to method sorry
the first one is get which allows you to
get the text available on the other one
set in order to change the available
text so here we have user message sorry
to get you just return to our and turn
and this one user message equal value
ok so this property which is in this
case it's called text will affect
actually the properties window what you
are going to see that later on
now what do we need next in this case we
need the time our control here so I'm
gonna place this timer and okay i don't
want women to check that it select this
one and the label controlling and change
its modifiers is that ok so how many
farms it's friend sorry friend i'm going
to make the private so that I getting to
know one access it
sorry
and the timer is also going to be
private
ok now the name of the time arms going
to be timer1 not problem and we're going
to display one letter every second and
generate member true enable this true
so what happens when the time our tix so
we're going to use this one private
letters displayed as integer equals 0
that's it so now what happens letter
display so letter displayed we call
letter displayed +1 and letter just
played mark what's that we see user
message
message . King wait a minute so just
turn
displayed equals system
ok there's another thing here have user
message called nothing and label1 not
feeling very well text you can nothing
can fix it so okay so there we go
and here this part is gonna tell me how
many litters display each time this code
executes displaying 1 extractor so now
label1 . x equal user message that
substrate 10 and the letter is displayed
it's going to be letters to the plate
plus one reason plus 1 because i'm
suffering the length and at first it's
it's going to be 0
ok so we have this one here as you can
see we're going to save this i'm going
to close this one now this is the label
i'm going to close this this is our form
right now the problem baby and that you
might face now is that ok where is the
control all you have to do is go to both
and serve both solution
ok and there you go it's here letter by
letter label so I'm gonna draw one here
ok so now our this you see that it just
disappeared
ok so all you have to do is go and
search for the text property the text
property creative will appeal appear
here
so where is the text should be content
and
sorry I think I'm doing something wrong
here because I can see the text property
I think go to the code that look at what
did i do here
public property texts as train return is
a message and it's ok it's a public
property
ok
I'm sorry there is already and property
called takes for the control and can
change that to other rights rights
I think like that I don't
ok so public overrides property takes
now what this means is that if there is
and a property called text associated
with the control i'm gonna get rid of
that property and i am going to create
my own
ok so this what overwrites mean so right
now if if we go to the design here you
rebuild the project again and now I go
and select this one I search your i'm
going to see the text than our pqr and I
can see it
surely i'm doing something wrong
gosh how come
let me see Rita
close this close this save this one this
one again
yeah sometimes it gets annoying
great DDT
come and see so this one is little by
little table
yeah
ok we have the property here i wonder
why doesn't appear on the building in
the properties window but it's alright
this is a test
ok so right now we have it here again
you can see so now I'm gonna run the
skirt and we're going to see what's
going to happen so few seconds okay now
look at this you can see the letters
appear letter sorry the label displaying
the texture by letter so that when it
finishes is going back to the beginning
ok so this is the control is how you can
see this property's ok now let me check
this again this is really strange
ok that means she here
property now double-click this one
double-click this so public property tax
this shouldn't have any effect but if
the tap it works is gonna come to
brighten crazy felt that again
yeah
okay you cannot figure out what the
problem is but what I'm going to do is
the following down i want to use the
same property tax i'm going to change
the name to special text
ok so now it is called a special text
I'm going to build this and now if i go
to the form designer click here and
search in the properties window i'm
going to find this is the special text
property
I don't know why it didn't work with the
text property because it's already
available and I got rid of it using the
overrides method and use my own I'm not
sure so sorry about that anyway so we're
going to say for example either
this is a test that and enter now as
soon as you press ENTER you can go and
see that the control is working during
design time
okay so everything looks nice right now
everything's working fine if you'd like
to you can run the code and have a look
at your form
ok so they do it's working now arm
ok so what are we going to do now is
that we are going to bundle this control
in sai daddy of all and we are going to
use it in another project so what should
you do
okay first of all I'm going to go and
change the project type into a class
library
ok this is the first thing I'm going to
save this next am going to get rid of
this form because i don't need it i only
need this control if you have modules
that the controls using you might want
to keep them there
okay i'm going to leave this form i'm
going to say is remove that and now i'm
going to build the solution
ok so now i have just finished building
the solution and now armed copy the full
bath and go to computer
and now look here go to be in debug this
is the dll ok so i'm going to copy this
ok copy this here go to the desktop
paste it here ok
there isn't am doing this I want you to
see that the dll file which continued to
controls now available here now we are
going to start your project file in your
project and we're going to forget all
about that little by little label now
how do you add this control your visual
studio all you have to do is go to tools
and choose two parts items
ok and now from this option with few
seconds okay and the video studio will
have to work to wait for a while until
able to
find all the available deals anyway so
select to browse go to work
dll file is this is the dll file I'm
going to say open and as you can see
it's your little bottle label they will
i am going to click ok and as soon as I
do that you can see that the table is
now available here i'm gonna use it here
just click it and draw it on the forum
here and now if I go to the words that
special text here
hello this is a user control and enter
by do this you can see now it's working
and right now this is part of the
available controls and I can use it in
any project
ok and now i'm running this as you can
see ok ok and if I now go and run in
your project here create new project now
if you go and check the available
controls you are going to see that it's
available here so you can use it all the
time it will be available for a long
time now there's something here if you
want to remove this from here all you
have to do is go to tools and choose to
box items wait a few seconds and okay
what was its name
I think it was the with 2 minutes
there's a problem i forgot the same as
it should be letter
wait a minute service by name to get l
wait LLL
this is it its letter by letter so here
are you just remove this from here
press ok and now this control is not
available individuals told you
everything is the same wine and then
sorry
everything is exactly the same way
towards bag and ok so this is how you
create a user control and how these are
you handle it inside the LOL you can
create multiple controls inside a single
dll file and use that ok help you find
this useful if you have questions please
send them to me
also check out the site www.kttape.com
for more tutorials and have to have a
nice thing

Video Length: 19:21
Uploaded By: mkaatr
Published: 4/7/2011
View Count: 52,320

Related Software Products
Visual Basic Activex Controls
Visual Basic Activex Controls

Published By:
helpsofts

Description:
Professional VB Activex Controls for visual basic 6.0 HVEE 2008 (VB ActiveX Controls) provides professional VB ActiveX Controls for Visual Basic (VB) that are easy to use and customize to give you the ability to quickly and easily create professional vb applications that have the latest visual styles and advanced features that are seen in such products as Microsoft Windows, XP, vista regardless of their operating system. Smart Professional User Interface (GUI) for VB or any activeX platforms . ...


Related Videos
Excel VBA ActiveX Controls #1 Worksheet Button and Textbox
Excel VBA ActiveX Controls #1 Worksheet Button and Textbox

Video Length: 07:04
Uploaded By: ExcelVbaIsFun (3/9/2013)
View Count: 229,097

how to create ActiveX control in vb 6
how to create ActiveX control in vb 6

Video Length: 04:37
Uploaded By: tps (10/19/2013)
View Count: 52,204

Excel 2010 VBA Tutorial 54 - ActiveX Controls - Command Button
Excel 2010 VBA Tutorial 54 - ActiveX Controls - Command Button

Video Length: 04:41
Uploaded By: YourProgrammingNetwork (8/5/2013)
View Count: 50,927

Adding VB ActiveX Controls - Checklist Survey in Microsoft Word 2010 (part 5 of 9)
Adding VB ActiveX Controls - Checklist Survey in Microsoft Word 2010 (part 5 of 9)

Video Length: 09:40
Uploaded By: Alex Cantu (9/18/2012)
View Count: 45,261

VB Macro Code for Checkbox - Functional Checklist Survey in Microsoft Word 2010 (part 7 of 9)
VB Macro Code for Checkbox - Functional Checklist Survey in Microsoft Word 2010 (part 7 of 9)

Video Length: 03:58
Uploaded By: Alex Cantu (9/18/2012)
View Count: 26,326

Excel 2010 VBA Tutorial 55 - ActiveX Controls - Text Box
Excel 2010 VBA Tutorial 55 - ActiveX Controls - Text Box

Video Length: 03:38
Uploaded By: YourProgrammingNetwork (8/5/2013)
View Count: 23,067

Excel 2010 VBA Tutorial 56 - ActiveX Controls - Drop Down Box
Excel 2010 VBA Tutorial 56 - ActiveX Controls - Drop Down Box

Video Length: 03:49
Uploaded By: YourProgrammingNetwork (8/5/2013)
View Count: 19,569

Form Filler ActiveX control (using Visual Basic 6.0)
Form Filler ActiveX control (using Visual Basic 6.0)

Video Length: 06:00
Uploaded By: DFPercush (6/13/2007)
View Count: 18,614

Excel 2010 VBA Tutorial 57 - ActiveX Controls - Spin Buttons
Excel 2010 VBA Tutorial 57 - ActiveX Controls - Spin Buttons

Video Length: 05:44
Uploaded By: YourProgrammingNetwork (8/7/2013)
View Count: 16,948

Copyright © 2026, Ivertech. All rights reserved.