Tutorials
VB.NET 2005
.NET Common Windows Forms Controls Part 2
.NET Common Windows Forms Controls Part 2 - Page 2
.NET Common Windows Forms Controls Part 2 - Page 3.
.
Tree Views are used to display a hierarchy of nodes. Each node can have several child nodes. A typical example of this is the Widows Explorer. In the Windows Explorer you can see the tree view of the directory of the drives. You can either expand all the levels or collapse the nodes just by clicking on them. When they are expanded, you can see all their children. You can also choose the icon that will be displayed for the node. If the CheckBoxes property is set to true, then you can see that the tree view shows a check box. Nodes and SelectedNode are the two main properties of this control. The Node property contains the list of nodes in the tree view. SelectedNode property gets or sets the currently selected node. The nodes collection for a node holds the node’s child TreeNode objects. You can add or remove or clone a TreeNode. Tree views also support other properties for navigating through them, node by node. The properties like FirstNode, lastNode, NextNode, PreNode, NextVisibleNode, PreVisibleNode are used for this purpose.
In contrast to the TreeView the ListView is used to list the items in the right side of the windows and it serves as complimentary to the TreeView. ListViews can display their items in four different methods viz., View.largeIcon, View.SmallIcon, View.list, and View.Details.
ListItems is the property of the Listview, that contains the items displayed by the control. The SelectedItems property contains a collection of the items currently selected in the control. If the multi-select property is set to true, then the user can select multiple item.
Timer Class is a component that is used to create periodic Tick events that to execute code at specific interval. Some of the properties, methods and events are given below:
|
Property/Method/Event |
Description |
|
Enabled |
Gets/Sets whether the timer is running |
|
Interval |
Gets/Sets the time in milliseconds between timer ticks |
|
Start |
Starts the timer |
|
Stop |
Stops the timer |
|
Tick |
Occurs the timer interval has elapsed |
The timer can be started or stopped using the method Start() and Stop(). The Tick event handler will be used to add codes that we need to manipulate the activity of the timer. Each tick event takes place at a default time of 100 milliseconds. This default value can be changed. The following demo illustrates the usage of the timer component.
To a new project in Visual Basic
Express add a timer component to the Form1.
Add two buttons.
Add the following code to the page:
The output generated by the program is shown below:
The startup screen is shown below:

When you press the Timer button, it calls the TimerStartStop method defined which starts the timer and throws a message box which you see below

When you click Ok in the MessageBox, it stops the timer. While the timer is running the Tick event handler is incrementing the value of the variable t by 100 for every tick, which is the default time it takes between two successive Tick events. The timer event is stopped and the value of t is assigned to t2 after dividing it by 1000 to convert to seconds. This value is now displayed using the last MessageBox.

Next Page: .NET Common Windows Forms Controls Part 2 - Page 3