Exforsys

VB.NET 2005

  1. VB.NET 2005 Free Training
  2. The .NET Framework Architecture Part 1
  3. The .NET Framework Architecture Part 2
  4. Application Class and Message Class
  5. Implementing Class Library Object
  6. Visual Studio.NET Namespaces
  7. .NET Assemblies
  8. Differences between VB.NET 1.0 and VB.NET 2.0
  9. Introducing VB.NET Windows Forms
  10. Visual Studio Windows Forms Designer
  11. Exploring the Forms Designer generated code
  12. Setting and Adding Properties to Windows Form
  13. Implementing Inheritance
  14. Event Handling In Visual Basic .NET
  15. Building Graphical Interface elements
  16. .NET Common Windows Forms Controls Part 1
  17. .NET Common Windows Forms Controls Part 2
  18. Common Controls and Handling Control Events
  19. DomainUpDown and NumericUpDown Controls
  20. Dialog Boxes in Visual Basic .NET
  21. Visual Studio Adding Controls to Windows Form
  22. VB.NET Validation Controls
  23. Working with Menu Controls
  24. VB.NET MDI Applications
  25. .NET Exceptions
  26. VB.NET Creating and Managing Components Part 1
  27. VB.NET Creating and Managing Components Part 2
  28. Simple Data Binding
  29. .NET Complex Data Binding
  30. .NET Data Form Wizard
  31. Data Manipulation with ADO.NET
  32. SQL Server Stored Procedures
  33. SQL Server Ad Hoc Queries
  34. Finding and Sorting Data in DataSets
  35. ADO.NET Object Model
  36. Working with DataSets
  37. Using XML Data
  38. Working with File System in .NET
  39. Creating Web Service
  40. Instantiating - Invoking Web Services, Creating Proxy Classes with WSDL
  41. Web Reference and Web Services
  42. Web Services - SOAP, WSDL, Disco and UDDI
  43. Web Application Testing in VB.NET 2005
  44. Web Application Tracing and Debugging
  45. Working with Legacy Code and COM Components
  46. ActiveX Controls and Legacy Code
  47. Windows Application Testing
  48. VB.NET Windows Application Testing
  49. Tracing VB.NET Windows Application
  50. Debugging Windows Applications In Visual Studio.NET 2005
  51. Deploying Windows Applications In Visual Studio.NET 2005
  52. Customizing Setup Project in Visual Studio.NET 2005
  53. Shared Assembly
  54. Microsoft .NET Creating Installation Components
  55. The Registry Editor in Visual Studio.NET 2005
  56. The File Types Editor

Ads


Home arrow Technical Training arrow VB.NET 2005

VB.NET Creating and Managing Components Part 1 Page - 2

Page 2 of 3
Author : Exforsys Inc.     Published on: 6th Jul 2005    |   Last Updated on: 22nd Jan 2009

VB.NET Creating and Managing Components Part 1

.

.

.

Ads

After adding the control to the ToolBox, you can also add three text boxes, two buttons and five labels and arrange them as you would see in the final output form shown below.

In the code editor add the following code to the Form1:

Click here for Sample Code

Now you can press F5 to execute the program. The output of the program is shown below:

Creating and implementing Events

In the example above validations for data entry have not been touched upon. In this section we shall see how validations can be added to the component. We shall assume a business rule that this calculator is used to calculate interest for Principal exceeding 100 for interest rate > 4 where the number of years is 2 or more.

For this purpose we shall create events. We shall also add programs to check the values and raise the events. The events that are raised will be handled in the windows application with the procedures that use the Handles keyword.

Events are declared using the keyword Event:

Event event name (Argument)

The event can be raised using the RaiseEvent keyword as shown below:

RaiseEvent event name

The modified code for the user control is given below:

Click here for Sample Code

The modified code for the windows application using this control is also shown below:

Click here for Sample Code

Now press F5 to execute the program. The following screenshots show us the way the three events are handled along with the normal termination of the program.

The error message



 

 

 

 

 

 

 

 

 

Extending a control through Visual Inheritance

The concept of Visual inheritance was introduced to facilitate the use and reuse of forms in VB.NET applications. It is Microsoft’s way of describing visual implementation of interfaces as objects. A base form is created and located in the class library project for use of multiple applications. When a form inherits from a base form, the controls on the base form appear in the derived form and cannot be modified if the modifier property of the base form has been set to Private or Friend. Therefore, if the derived form is to have the option of modifying the controls, the base form should have the control modifier properties set to Public or Protected.

The base form project will have to be compiled every time changes are made to the form. A change in one location will impact on all forms derived from the base form if the modifier property of the form is set to Private or Friend.

To derive a form object, the user has to simply add a new inherited form to his project. The inheritance picker will be launched and the user will be prompted to identify the base form. The application developer can choose the form available in the same assembly or can add another assembly and inherit a form from that assembly. In this case the developer will have all the display components of the parent form available to the newly added form.

Visual inheritance enables the programmers create user interfaces with ease. The capacity to inherit controls along with the form makes for rapid application development and generation of customized controls becomes easier.



 
This tutorial is part of a VB.NET 2005 tutorial series. Read it from the beginning and learn yourself.

VB.NET 2005

  1. VB.NET 2005 Free Training
  2. The .NET Framework Architecture Part 1
  3. The .NET Framework Architecture Part 2
  4. Application Class and Message Class
  5. Implementing Class Library Object
  6. Visual Studio.NET Namespaces
  7. .NET Assemblies
  8. Differences between VB.NET 1.0 and VB.NET 2.0
  9. Introducing VB.NET Windows Forms
  10. Visual Studio Windows Forms Designer
  11. Exploring the Forms Designer generated code
  12. Setting and Adding Properties to Windows Form
  13. Implementing Inheritance
  14. Event Handling In Visual Basic .NET
  15. Building Graphical Interface elements
  16. .NET Common Windows Forms Controls Part 1
  17. .NET Common Windows Forms Controls Part 2
  18. Common Controls and Handling Control Events
  19. DomainUpDown and NumericUpDown Controls
  20. Dialog Boxes in Visual Basic .NET
  21. Visual Studio Adding Controls to Windows Form
  22. VB.NET Validation Controls
  23. Working with Menu Controls
  24. VB.NET MDI Applications
  25. .NET Exceptions
  26. VB.NET Creating and Managing Components Part 1
  27. VB.NET Creating and Managing Components Part 2
  28. Simple Data Binding
  29. .NET Complex Data Binding
  30. .NET Data Form Wizard
  31. Data Manipulation with ADO.NET
  32. SQL Server Stored Procedures
  33. SQL Server Ad Hoc Queries
  34. Finding and Sorting Data in DataSets
  35. ADO.NET Object Model
  36. Working with DataSets
  37. Using XML Data
  38. Working with File System in .NET
  39. Creating Web Service
  40. Instantiating - Invoking Web Services, Creating Proxy Classes with WSDL
  41. Web Reference and Web Services
  42. Web Services - SOAP, WSDL, Disco and UDDI
  43. Web Application Testing in VB.NET 2005
  44. Web Application Tracing and Debugging
  45. Working with Legacy Code and COM Components
  46. ActiveX Controls and Legacy Code
  47. Windows Application Testing
  48. VB.NET Windows Application Testing
  49. Tracing VB.NET Windows Application
  50. Debugging Windows Applications In Visual Studio.NET 2005
  51. Deploying Windows Applications In Visual Studio.NET 2005
  52. Customizing Setup Project in Visual Studio.NET 2005
  53. Shared Assembly
  54. Microsoft .NET Creating Installation Components
  55. The Registry Editor in Visual Studio.NET 2005
  56. The File Types Editor
 

Comments