|
Page 1 of 3
.NET Common Windows Form Controls part 2
In this tutorial we will learn about Common Windows Forms Controls in Visual Basic .NET 2005. In this part 2 of this article, We will be learning the controls like Control MonthCalendar and DateTimePicker, TreeView and ListView, Timer, TrackBar and ProgressBar, HScrollBar and VScrollBar,
MonthCalendar
MonthCalendar is a very useful tool that has been added to the .NET Framework. Let us see how this works with an example. In a new project add a textbox and a command box to the form and also date time picker. In the code window add the following code:
Click here for Sample Code
The first screenshot shows the screen with the date time picker.

This screenshot shows the selected value in the textbox and the date time picker is hidden.

DateTimepicker
This control allows the user to select dates and times. Some of the important property of this class is given as below:
|
Property/evnets
|
Description
|
|
MaxDateTime
|
Sets the maximum date value of the date time picker control
|
|
MinDateTime
|
Sets the minimum date value of the date time picker control
|
|
Format
|
Gets/Sets the format of the date and time
|
|
MaxDate
|
Gets/Sets the maximum selectable date and time
|
|
MinDate
|
Gets/Sets the minimum selectable date and time
|
|
Value
|
Gets/Sets the date and time value
|
|
Closeup
|
When the drop-down calendar disappears
|
|
DropDown
|
When the drop down calendar appears
|
|
FormatChanged
|
When the format property value changes
|
|
ValueChanged
|
When the value property changes
|
The Windows Form’s DateTimePicker control allows the user to select a single item from a list of dates or times. When used to represent a date, it appears in two parts: a drop-down list with a date represented in text, and a grid that appears when you click on the down-arrow next to the list. The grid looks like the MonthCalendar control, which can be used for selecting multiple dates.
An alternative to the grid, useful for editing times instead of dates, is the up and down buttons that appear when the ShowUpDown property is set to true. When the ShowCheckBox property is set to true, a check box is displayed next to the selected date in the control. When the check box is checked, the selected date-time value can be updated. When the check box is empty, the value appears unavailable.
The following example explains the use of the DateTimePicker and the DateTimePicker1.ValueChanged event.
-
To a new project add to the Form1 a DateTimPicker control from the toolbox.
-
Double click on the control to open the editor for the DateTimePicker1.ValueChanged event.
-
Add the codes given below:
Click here for Sample Code
The output shows the various values that are extracted from the DateTimePicker. The following four screenshots show the sequence of events in executing the program.

The values are shown as the caption.



|