Class DateEditor
Provides date editing functionality using TextValidateField with culture-aware formatting.
public class DateEditor : TextValidateField, IDisposable, ISupportInitializeNotification, ISupportInitialize, IValue<string>, IValue<DateTime>, IValue, IDesignable
- Inheritance
-
DateEditor
- Implements
- Inherited Members
- Extension Methods
Remarks
DateEditor extends TextValidateField with date-specific functionality:
<ul><li>Uses <xref href="Terminal.Gui.Views.DateTextProvider" data-throw-if-not-resolved="false"></xref> for validation and formatting</li><li>
Supports culture-specific date formats via <xref href="System.Globalization.DateTimeFormatInfo" data-throw-if-not-resolved="false"></xref>
</li><li>Cursor automatically skips over separator characters</li><li>Auto-adjusts width based on date pattern</li></ul>
Usage Examples:
// Use default (current culture's short date pattern)
DateEditor dateEditor = new () { Value = new DateTime (2024, 3, 15) };
// en-US displays: "03/15/2024"
// en-GB displays: "15/03/2024"
// Use specific culture's format
dateEditor.Format = CultureInfo.GetCultureInfo ("de-DE").DateTimeFormat;
// Displays: "15.03.2024"
Constructors
- DateEditor()
Initializes a new instance of the DateEditor class.
Properties
- Format
Gets or sets the DateTimeFormatInfo used for date formatting.
- Value
Gets or sets the current date value.
Methods
- HandleProviderTextChanged(string, string)
Handles provider text changes for DateEditor by raising DateTime-typed value events instead of string-typed events.
- OnValueChanged(ValueChangedEventArgs<DateTime>)
Called when the Value has changed. Allows derived classes to react to value changes.
- OnValueChanged(ValueChangedEventArgs<string?>)
Synchronizes the DateTime backing field when the base class Text property changes programmatically.
- OnValueChanging(ValueChangingEventArgs<DateTime>)
Called when the Value is about to change. Allows derived classes to cancel the change.
Events
- ValueChanged
Raised when Value has changed.
- ValueChangedUntyped
Raised when Value has changed, providing the value as an un-typed object.
- ValueChanging
Raised when Value is about to change. Set Handled to true to cancel the change.