TimeOfDayTextBox and DurationTextBox Control
Back
There are two types of time: time of day and duration. The time of day reflects
a 24 hour period and users use two formats to enter it: 12 or 24 hour. The duration
reflects a length of time. Users also use two formats to enter it: HH:MM:SS or decimal
(3:30 or 3.5).
Peter's Date and Time offers separate TextBox controls for each of these types of
time: TimeOfDayTextBox and DurationTextBox. Both have extensive features to make
data entry easy and familiar.
Product Features
Here are the defaults for both textboxes to use while reviewing these features.
Data Entry in the TextBox
Popup TimePicker
You can add a PopupTimePicker to assist the user in selecting a time from a fixed
list.
You can even make the textbox ReadOnly so the user must use the TimePicker or arrow
buttons to assign the time value.
Add the UnselectableTimesValidator to report errors when the user does not pick
a time found in the TimePicker or from a time interval rule (such as on 30 minute
increments).
Other Features
- Supports databinding on its value.
- The time value can be represented by a DateTime structure or TimeSpan structure,
both which are defined in the .Net framework. The TimeSpan structure has methods
to convert to and from numerous other values such as number of seconds and number
of hours.
-
TimeOfDayTextBox can be used as a companion to a
DateTextBox.
Start by linking the TimeOfDayTextBox to a DateTextBox. Then you can set and get
a DateTime structure, with both date and time into the TimeOfDayTextBox’s xDateTime
property and it will update both fields. In addition, its commands to increment
minutes or hours will wrap around at midnight, incrementing the DateTextBox too.
Finally, the validators can evaluate the two controls as a single Date+Time value.
In this example, we've connected a TimeOfDayTextBox to a DateTextBox. When configured
this way, you can assign and retrieve one DateTime structure representing both controls.
Unfortunately, you can't see that in a demo. But you can see how using the arrows
will change the date as it hits the minimum and maximum. Also use the Now command
in the TimeOfDayTextBox (from the Help button or Ctrl+N) to see both fields filled
in.
- You can build a time range entry tool by adding two TimeOfDayTextBoxes or DurationTextBoxes
to your form. Use the TimeTextBoxCompareValidator to validate the users entry so
that the first time will be less than or equal to the second. If you have a date
and time, add DateTextBoxes and the validator will include the dates in this validation.
Back
|