Version

TimeSpanEditor Class

EditorWithText derived embeddable editor which parses and formats TimeSpan values.
Syntax
'Declaration
 
Public Class TimeSpanEditor 
   Inherits EditorWithText
   Implements IEmbeddableTextBoxListener 
public class TimeSpanEditor : EditorWithText, IEmbeddableTextBoxListener  
Remarks

The TimeSpanEditor is based on the 'Duration' field editor of the task grid seen in MS Project. It is designed to format TimeSpans, and parse string representations of TimeSpans. The TimeSpanEditor preserves the unit of time expression as input by the user; for example, if the user enters "1 day" into the edit portion, the unit of time (days) is persisted between edit mode sessions

The TimeSpanEditor does not utilize masking; it derives from EditorWithText and allows free-form typing within the edit portion. When values are inputted that cannot be parsed into a TimeSpan, the IsValid property returns false. Embeddable editor consumers such as the UltraGrid interpret this as an error condition, and prompt the user accordingly via the usual mechanisms.

The TimeSpanEditor displays "spin" buttons by default, which when clicked increment/decrement the current value. These buttons can be hidden by setting the SpinButtonVisible property to false.

The TimeSpanEditor supports the editing and rendering of three types: System.TimeSpan, Nullable(Of System.TimeSpan), and FormattedTimeSpan. The latter is a simple proprietary Infragistics type which wraps the TimeSpan structure, and adds one additional property, Format, which is an enumeration that describes the unit of time (weeks, days, hours, or minutes).

When used to edit and render the TimeSpan data type, the associated embeddable editor owner must implement the GetEditorContext and SetEditorContext methods in order to preserve the unit of time representation. When used within an UltraGrid, this mechanism is already in place as it is used for other purposes, so when consumed within the UltraGrid, this need not be a concern for the developer.

The associated embeddable editor owner can optionally implement the GetExtendedInfo method to provide enhanced formatting support extended by the TimeSpanFormatInfo class. This class provides the ability to explicitly define the strings used to represent the units of time; for example, to support use within a spanish-speaking culture, the values "semana", "día", "hora", and "minuto" would be assigned to the appropriate properties. Additionally, this class can be used to define the number of days which comprise a logical week. MS Project, for example, considers the value "1 wk" to represent an actual span of time equal to five days rather than seven (since the default working week consists of five days).

The TimeSpanEditor constructor is overloaded to accept an instance of the TimeSpanFormatInfo class. Using this constructor results in the creation of an internal EmbeddableEditorOwnerBase-derived implementation which overrides the methods necessary to communicate with the editor.

The TimeSpanEditor does not support units of time less than one minute in duration.

Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also