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 1 of 2
Author : Exforsys Inc.     Published on: 20th Jun 2005    |   Last Updated on: 24th Dec 2007

Common Controls and Handling Control Events

In this tutorial we will be learning how to use common control like Control Hierarchy, Label and LinkLabel, TextBox and RichTextBox, PictureBox, GroupBox and Panel, Button, CheckBox and RadioButton, ListBox, CheckedListBox and ComboBox, DomainUpDown and NumericUpDown, MonthCalendar and DateTimePicker, TreeView and ListView, Timer, TrackBar and ProgressBar, HScrollBar, VScrollBar, TabControl and Handling Control Events.

Ads

All controls are governed by the Control Class “System.Windows.Forms” Namespace. This class handles the entire basic window handle (HWND) functionality such as the creation and destruction of windows handles. When Control and Rich Control are integrated VB.NET provides for greater functionality.

A number of properties are shared by all controls in a class. Any change in such shared properties impacts on all controls in the class. Some of the shared properties are listed below.

DefaultBackColor: Read-only. Returns what the background color of the control would be if the background color were set explicityly

DefaultFont: Read-only. Returns what the font of the control would be if the font were set explicitly

DefaultForeColor: Read-only. Returns what the foreground color of the control would be if the fore ground color is changed.

Public Shared Properties

Public shared properties are distinct from properties that are shared by controls of a class in that the value of the property is not shared across the controls in a class. Any change in the property of a control does not result in a change in the properties of the controls in the class. Even when two instances of an object are created, each can have a distinct value assigned to a property. Examples of public instance properties are listed below for your understanding.

AccessibilityObject
Specified the AccessibleObject assigned to the control.
BackColor
Specifies the background color
Cursor
Specifies the cursor that is displayed when the mouse pointer moves over the control
Focused
Read-only. Returns whether the control currently as the input focus.
Size
Specifies the size of the control
Anchor
Specifies which edges of the control are bound to the edges of its container
Dock
Specifies to which edge of the container the control is docked. When specified, the resizing of the control is handled automatically. Controls that are “dockable” require code analyzing window movements coupled with the setting of this property
Font
Specifies the current font of the control
Location
Specifies the coordinates of the upper-left corner of the control relative to the upper-left corner of the controls container
Name
Specifies the name of the control. This value is typically used to refer to the control in code
Size
Specifies the height and width of the full control
TabIndex
Specifies this control’s place in the tab order for all controls within the same container
TabStop
Specifies whether the control can receive focus via the tab key
Visible
Specifies whether the control is visible
Enabled
Specifies whether the control is enabled. This also covers items such as receiving focus

Configuring the order of tabs

A user is required to move across a form in a prescribed order. The tab order of the control determines the way in which the cursor moves in the form and takes the user through the various options created for his use. This is a very important property for the application designer as it determines the sequence of user input if any.

Click on the control in the form and edit the TabIndex property and change its value. The value for this property is given in integers. This will be enabled only if the TabStop Property is set to true. Let us see an example for this feature.

  1. Create a new project in the visual Studio IDE and add a form.
  2. Drag and add 18 Command Buttons to this form and arrange them in a matrix.
  3. Pick any 6 of them and select them.
  4. Set the property enabled to false.
  5. This can also be done at runtime as shown in the example.
  6. Position two buttons separately as shown in the from.
  7. You can also add two labels one at the top and the other at the bottom.
  8. For each of the remaining Buttons do the following changes:
    1. From the first button on the top left change their name in order and give them a new name (First, Second … Tenth)
    2. You will find that the TabIndex value would have already been set as per the order of their placement in the form.
    3. Change their values so that the label named first will have the value 1 and the label that has the name Tenth will have a value 10.

Ads

At the bottom of the form you will have one label control and two command buttons. Set the name value for the label as null and that of the first command button to “Reverse Order!”. Let the name of the second command button be “Exit”. Now your form will look like the screenshot given below.



You have to add the following lines of code to the project:

Click here for Sample Source Code

Execute the project by pressing F5. This example illustrates the purpose of the properties and also the method used to assign the properties at run time. Please note that the property TabStop is not available to all properties. For example the controls like Label and LinkLabel do not expose this property.



 
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