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

Common Controls and Handling Control Events Page - 2

Page 2 of 2
Author : Exforsys Inc.     Published on: 20th Jun 2005    |   Last Updated on: 24th Dec 2007

Common Controls and Handling Control Events

Handling Control Events

Controls are used as a primary medium of handling events. Rich set of events are specified for controls and their nature can be easily understood by reading their names. For example OnClick, MouseEnter, MouseLeave etc. describe the nature of the event they handle. Some of the events and their descriptions are given below:

Event Name
Description
BackColorChanged
Occurs when the BackClolor property of the control is changed
BindingContextChanged
Occurs when the BindingContext property of the control changes
ChangeUICues
Occurs when focus or keyboard cues changes
ContextMenuChanged
Occurs when the Contextmenu Property of the control is changed
KeyUp
Occurs when a key is released while the control has focus
Move
Occurs when the control is moved
Resize
Occurs when the control is resized
Paint
Occurs when the control is drawn or redrawn
LocationChanged
Occurs when the location property of the control changes
Validating
Occurs when the visible property of the control changes

Ads

All controls have been declared with the functionalities built into them and therefore are capable of executing the function when the user calls the event. This process is enabled by using the term “Handles”. The program that is executed will look like the one below.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

------------

------------

End Sub

The event handler takes two parameters in the above instance. The first is the sender as System.Object and the other is the valued ‘e’ as System.EventArgs. The Sender defines the object that has raised the event and the EventArg contains all the event specific data that the event sender passes.

There are other types of arguments that are accepted, such as FileSystemEventAtrgs, ImageClickEventArgs, KeyEventArgs and CommandEventArgs. Using the SenderObject could be particularly useful if a any action from out of a set of grouped actions is to be performed. Let us look at an example of this.

Start a new Visual Basic Windows Application Project in the Visual Studio IDE.

Add seven buttons and four labels and rename the buttons as shown as shown in the following screenshot.

Two labels label3 and label4 are not visible as the text is set to null. Now add the code as given below:

Click here for Sample Source Code

Ads

Here, we have used a CommonHandler that does some action based on the output of the various events. This is a simple code that changes the text of the labels. You can also write complex codes using loops that perform some action based on the event of the object that has sent the event. This facility is very useful in solving complex problems with simple solutions quickly.

In the next chapter we will learn about Common Dialog Boxes and Creating a Custom Dialog Box in Visual Studio .NET 2005 using Visual Basic.NET 2005.



 
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