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

.NET Common Windows Forms Controls Part 1

Page 1 of 3
Author : Exforsys Inc.     Published on: 26th Jun 2005    |   Last Updated on: 6th Apr 2011

.NET Common Windows Forms Controls

In this tutorial we will learn about Common Windows Forms Controls in Visual Basic .NET 2005. IN this part 1 of this article, We will be learning the controls like Control Hierarchy, Label, LinkLabel, TextBox, RichTextBox, PictureBox, GroupBox, Panel, Button, CheckBox , RadioButton, ListBox, CheckedListBox and ComboBox.

Control Hierarchy

Ads

The base class for all Windows controls is located in the System.Windows.Forms namespace. These controls are built into the .NET framework and form the basis for derived controls. These controls have a distinct hierarchy of their own. For example the hierarchy of the control rich text box is given below:

Object

MarshalByRefObject

Component

Control

TextBoxBase

RichTextBox

We shall take a quick look at some of the properties of the control:

Property

Description

AllowsDrop

Value that decides to accept data dropped in to it

Anchor

Gets/Sets the value of edges of the control to be anchored

BackColor

Gets/sets value of the color of the Background

CanFocus

Returns a value which specifies id the control can receive focus

DataBinding

Gets the data bindings for the control

Parent

Gets/Sets the controls parent container

Visible

Gets/Sets the value determines the visibility of the control

Some of the methods of the control are listed below:

Method

Description

BringToFront

Brings the control to the front of the stacking

Contains

Retrieves a value specifying if the control is a child of this control

Dispose

Releases the resources used by the control

GetType

Gets the type of the control

Hide

Hides the control

Invalidate

Invalidates a part of the control and sends a paint message to the control

DoDragDrop

Starts a drag and drop operation

Some of the events of the control are listed below:

BackgroundChanged

When the value of the backColor property is changed

Click

When mouse is clicked on the control

ControlAdded

When a new control is added

ControlRemoved

When a control is removed

SursorChanged

When the cursor property value ischanged

DragEnter

When an object is dragged into the control’s bounds

Enter

When the control is entered

GotFocus

When the control receives focus

Leave

When the location property value is changed

MouseWheel

When the mouse wheel moves whild the control has focus

VisibleChanged

When the Visible property value is changed

The above list is not exhaustive. However, a designer would find it profitable to get himself acquainted with the properties and methods of the different types of controls that he uses. Derived controls are customized controls that use the .NET framework controls as a base for building upon.

Label

The Label control is used in a number of applications to indicate the nature of the input required or the name of a control or just to convey a message to the user. The autosize property of this control is true by default, but can be dynamically fixed. Since this control cannot receive focus, it can also be used to create access keys for other controls.

Let us see a demo for this activity:

  • Draw the label first, and then draw the other control. Other wise draw the controls in any order and set the System.Windows.Forms.Control.TabIndex property of the label to one less than the other control.
  • Set the label's System.Windows.Forms.Label.UseMnemonic property to true.
  • Use an ampersand (&) in the label's System.Windows.Forms.Label.Text property to assign the access key for the label. For more information, see Creating Access Keys for Windows Forms Controls.
  • The following code will accomplish the task. Press F5 and see the demo in action.

Click here for the Sample Code

The output of the above codes is shown in the screenshot pasted below:

Link Labels

Ads

This control is similar to the Label Control. In addition to all the properties, methods, and events of the Label control, the LinkLabel control has properties for hyperlinks and link colors. The LinkLabel.LinkArea property sets the area of the text that activates the link. The LinkLabel.LinkColor, LinkLabel.VisitedLinkColor, and LinkLabel.ActiveLinkColor properties set the colors of the link. The LinkLabel.LinkClicked event determines what happens when the link text is selected.

Link Labels are labels that support hyper links. Some of the important properties and events are given below:

Property/Event

Description

ActiveLinkColor

Gets/Sets the color for an active link

DisabledLinkColor

Gets/sets the color for an inactive link

LinkArea

Gets/Sets the range of that will be treated as link

LinkBehaviour

Gets/Sets the value that represents the behavior of a link

LinkColor

Gets/Sets the color of the link

LinkVisited

Gets/Sets the value specifying if a link should be displayed as though it had been visited

VisitedLinkColor

Gets/Sets the color used for the links that have been visited

The following code snippet demonstrates the usage of the link label.

Click here for the Sample Code

TextBox

The hierarchy of the control Text Box is given below:

Object

MarshalByRefObject

Component

Control

TextBoxBase

Text Box

This control is used mainly to collect user input of data and display text. The look and feel and the behavior can be controlled by manipulating the values of its properties, invoking some methods and also handling some of the events that this control is enabled to handle.

Some of the methods, properties and events of the text box are given below:

Property/Method/Event

Description

AutoSize

Sets/Gets value specifying if the control can resize itself automatically.

CanUndo

Return a value specifying if the user can undo the previous operation

Modified

Indicates if the text box control ha been modified by the user since the control was created or its contents were lost

Multiline

Sets/Gets value to determine if this is a multi-line text box control

SelectiedText

Sets/Get value for the currently selected text in the control box

SelectionLength

Sets/Gets value of number of characters selected

TextAlign

Gets/Sets how the test is aligned in the text box

WordWrap

Indicates if a multiline text box control automatically wraps the words

AppendText

Append textx to the current text in the text box

Clear

Clears all the text in the text box

Copy

Copies the selected text to the clipboard

Cut

Copies the selected text to the clip board and clears the text box

Select

Selects the text in the text box

Undo

Undoes the last edit operation in the text box

AutoSizeChanged

When the value of the autosizeproperty is changed

Click

When the text box is clicked

ReadonlyChanged

When the value of the readOnly property changed




 
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