Examples of User Controls in VB.NET

With the user controls you can easily combine different controls and make them as a single control and even add them to the toolbox. After you add them to the tool box you can just drag and drop them as you would with the other controls in the toolbox to add them to in the design view.

For example if you want to create a user control that would have a label and a textbox together, then you can create a new project using the Visual Studio .Net and select the option of Web Control Library.

This would create the .ascx file needed for creating the user control. Now you can drag and drop the label and a textbox in the design view. Double click to open the code window and in that you can set the properties for the label and the text box as given below in VB.Net.

Public Property propText() As String
Get
propText = TextBox1.Text
End Get
Set(ByVal txtValue As String)
TextBox1.Text = txtValue
End Set
End Property
Public Property propLbl() As String
Get
propLbl = Label1.Text
End Get
Set(ByVal lblValue As String)
Label1.Text = lblValue
End Set
End Property

Once you have created such a user control, now you can right click the toolbox and select customize. Now add the .dll file that is created and you will find the user control created be added to the toolbox palette. Now you are ready to use the user control as you would with the other controls in the toolbox.

A simple search on the internet would provide you with a lot of such examples of user controls in VB.Net.





______________________________________________________

Recommended Resource



| Converting Web Pages to User Controls in .NET | .Working on .NET User Controls | Overview of ASP.NET User Controls | Web User Controls - Creation and Implementation | Advantages of using User Controls in ASP.NET | Re-usability of User Controls in ASP.NET | Personalizing Web Application by Creating User Controls in .NET | Customizing your Application with VB.net User Controls | Building User Controls in ASP.NET | Examples of User Controls in VB.NET | Example of C# User Controls | Where to use Visual Basic User Controls | Working on User Interface Controls | Creating Dynamic User Controls | Understanding VB .NET User Controls | Creating User Controls VB.NET | How to load user controls dynamically |

 

“Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.”

| Privacy Policy for www.dotnet-guide.com | Disclosure | Contact |

Copyright - © 2004 - 2024 - All Rights Reserved.