Version

Setting Time Span Values

The following example code illustrates on setting time span values and formatting them. A specific time span can be set using the TimeSpan property. The minimum and maximum values can be set for the TimeSpanEditor using the MinValue and MaxValue properties. The time span values can be formatted using the Format property.

In Visual Basic:

' Create a time span value to set the intial value for ultraTimeSpanEditor
Dim toStartWithValue As New TimeSpan(4, 0, 0, 0)
' Create minimum and maximum time span values
Dim minValue As New TimeSpan(1, 0, 0, 0)
Dim maxValue As New TimeSpan(20, 0, 0, 0)
' Set the initial time span value
Me.ultraTimeSpanEditor1.TimeSpan = toStartWithValue
' Set minimum and maximum time span values for ultraTimeSpanEditor
Me.ultraTimeSpanEditor1.MinValue = minValue
Me.ultraTimeSpanEditor1.MaxValue = maxValue
' Set the unit of time to days
Me.ultraTimeSpanEditor1.Format = TimeSpanFormat.Days
' Set the string to be displayed when the number of days is more than one
Me.ultraTimeSpanEditor1.FormatInfo.DayDisplayStringPlural = "DAYS"
' Do not display the spin button
' this.ultraTimeSpanEditor1.HasSpinButton = false;
' Fire the event when the value within ultraTimeSpanEditor changes.
AddHandler Me.ultraTimeSpanEditor1.ValueChanged, AddressOf ultraTimeSpanEditor1_ValueChanged
Private Sub ultraTimeSpanEditor1_ValueChanged(ByVal sender As Object, ByVal e As EventArgs)
    ' TODO: Implementation logic for value changed
End Sub

In C#:

// Create a time span value to set the intial value for ultraTimeSpanEditor
TimeSpan toStartWithValue = new TimeSpan(4, 0, 0, 0);
// Create minimum and maximum time span values
TimeSpan minValue = new TimeSpan(1, 0, 0, 0);
TimeSpan maxValue = new TimeSpan(20, 0, 0, 0);
// Set the initial time span value
this.ultraTimeSpanEditor1.TimeSpan = toStartWithValue;
// Set  minimum and maximum time span values for ultraTimeSpanEditor
this.ultraTimeSpanEditor1.MinValue = minValue;
this.ultraTimeSpanEditor1.MaxValue = maxValue;
// Set the unit of time to days
this.ultraTimeSpanEditor1.Format = TimeSpanFormat.Days;
// Set the string to be displayed when the number of days is more than one
this.ultraTimeSpanEditor1.FormatInfo.DayDisplayStringPlural = "DAYS";
// Do not display the spin button
// this.ultraTimeSpanEditor1.HasSpinButton = false;
// Fire the event when the value within ultraTimeSpanEditor changes.
this.ultraTimeSpanEditor1.ValueChanged += new EventHandler(ultraTimeSpanEditor1_ValueChanged);
void ultraTimeSpanEditor1_ValueChanged(object sender, EventArgs e)
{
   // TODO: Implementation logic for value changed
}