TimeSpanEdit Class
The editor to display and edit time intervals.
Namespace: DevExpress.XtraEditors
Assembly: DevExpress.XtraEditors.v19.1.dll
Declaration
[SmartTagFilter(typeof(TimeSpanEditFilter))]
[ToolboxBitmap(typeof(ToolboxIconsRootNS), "TimeSpanEdit")]
public class TimeSpanEdit :
TimeEdit
Related API Members
The following members return TimeSpanEdit objects:
Remarks
A TimeSpanEdit editor is designed to visually represent data stored in the System.TimeSpan format. The editor contains the following visual elements (see the figure below):
- Edit Box - a text field that displays the textual representation of the current time span. Displayed text is formatted according to the RepositoryItem.DisplayFormat property settings. If the RepositoryItem.ReadOnly property does not equal true, end-users can modify the time span directly from this edit box without invoking the drop-down (in this case, the editor switches to edit mode and its current value is visualized according to the MaskProperties.EditMask property value). RepositoryItem.EditFormat
- Drop-down button - a button that invokes the drop-down panel.
- Drop-down panel - a panel that displays the current time span and allows end-users to modify it. Can display the entire time span (days, hours, minutes and seconds) or only particular time units. Use the RepositoryItemTimeSpanEdit.AllowEditDays, RepositoryItemTimeSpanEdit.AllowEditHours, RepositoryItemTimeSpanEdit.AllowEditMinutes, RepositoryItemTimeSpanEdit.AllowEditSeconds and RepositoryItemTimeSpanEdit.AllowEditMilliseconds properties to specify which time units can be edited from within the drop-down panel.
The following code illustrates how to display a time span obtained by subtracting one DateTime value from another.
namespace timespan {
public partial class Form1 : XtraForm {
DateTime NYDate = new DateTime(2015, 1, 1, 0, 0, 0, 0);
public Form1() {
InitializeComponent();
timeSpanEdit1.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom;
timeSpanEdit1.Properties.DisplayFormat.FormatString = "{0:dd} days, {0:hh} hours, {0:mm} minutes and {0:ss} seconds";
timeSpanEdit1.Properties.ReadOnly = false;
timeSpanEdit1.Properties.Mask.EditMask = "dd:HH:mm:ss";
RefreshTimer();
}
private void RefreshTimer() {
DateTime currentDate = DateTime.Now;
TimeSpan timeToNY = NYDate - currentDate;
timeSpanEdit1.EditValue = timeToNY;
}
private void simpleButton1_Click(object sender, EventArgs e) {
RefreshTimer();
}
private void timeSpanEdit1_EditValueChanged(object sender, EventArgs e) {
labelControl1.Text = timeSpanEdit1.Properties.GetDisplayText(timeSpanEdit1.EditValue) + " left for the New Year!";
}
}
}
Implements
Inheritance
See Also