DateTimePickerExtensions
Namespace: Wisej.Web.Markup
Assembly: Wisej.Framework (4.1.0.0)
Adds fluent markup extension methods to the DateTimePicker class.
- C#
- VB.NET
public class DateTimePickerExtensions
Public Class DateTimePickerExtensions
Methods
CustomFormat<TDateTimePicker>(dateTimePicker, format)
Sets a custom date and time format string for the specified DateTimePicker control.
| Parameter | Type | Description |
|---|---|---|
| TDateTimePicker | The type of the date time picker, which must inherit from DateTimePicker. | |
| dateTimePicker | TDateTimePicker | The date time picker for which to set the custom format. |
| format | String | The custom format string to be applied to the date time picker. |
Returns: TDateTimePicker. The date time picker with the updated custom format.
This method sets the Format property to Custom and applies the specified custom format string.
myDateTimePicker.CustomFormat("MMMM dd, yyyy - dddd");
Format<TDateTimePicker>(dateTimePicker, format)
Sets the format for displaying date and time in the specified DateTimePicker control.
| Parameter | Type | Description |
|---|---|---|
| TDateTimePicker | The type of the date time picker, which must inherit from DateTimePicker. | |
| dateTimePicker | TDateTimePicker | The date time picker for which to set the format. |
| format | DateTimePickerFormat | The format to be applied to the date time picker, specified as a DateTimePickerFormat value. |
Returns: TDateTimePicker. The date time picker with the updated format.
This method allows you to set the format of the date and time displayed in the date time picker using predefined formats.
myDateTimePicker.Format(DateTimePickerFormat.Short);
MaxDate<TDateTimePicker>(dateTimePicker, value)
Sets the maximum date and time that can be selected in the specified DateTimePicker.
| Parameter | Type | Description |
|---|---|---|
| TDateTimePicker | The type of the DateTimePicker. | |
| dateTimePicker | TDateTimePicker | The DateTimePicker to set the maximum date for. |
| value | DateTime | The maximum date and time value to set. |
Returns: TDateTimePicker. The DateTimePicker with the updated maximum date.
This method allows you to specify the latest date and time that can be selected by the user.
var dateTimePicker = new DateTimePicker();
dateTimePicker.MaxDate(new DateTime(2023, 12, 31));
MinDate<TDateTimePicker>(dateTimePicker, value)
Sets the minimum date and time that can be selected in the specified DateTimePicker.
| Parameter | Type | Description |
|---|---|---|
| TDateTimePicker | The type of the DateTimePicker. | |
| dateTimePicker | TDateTimePicker | The DateTimePicker to set the minimum date for. |
| value | DateTime | The minimum date and time value to set. |
Returns: TDateTimePicker. The DateTimePicker with the updated minimum date.
This method allows you to specify the earliest date and time that can be selected by the user.
var dateTimePicker = new DateTimePicker();
dateTimePicker.MinDate(new DateTime(2023, 1, 1));
OnValueChanged<TDateTimePicker>(dateTimePicker, action)
Attaches an event handler to the ValueChanged event.
| Parameter | Type | Description |
|---|---|---|
| TDateTimePicker | The type of the DateTimePicker. | |
| dateTimePicker | TDateTimePicker | The DateTimePicker to attach the event handler to. |
| action | Action<TDateTimePicker> | The action to perform when the value changes. |
Returns: TDateTimePicker. The DateTimePicker with the event handler attached.
This method allows you to execute a specified action whenever the value of the DateTimePicker changes.
var dateTimePicker = new DateTimePicker();
dateTimePicker.OnValueChanged(picker => AlertBox.Show(picker.Value));
Value<TDateTimePicker>(dateTimePicker, value)
Sets the value of the specified DateTimePicker control and returns the control.
| Parameter | Type | Description |
|---|---|---|
| TDateTimePicker | The type of the DateTimePicker control. | |
| dateTimePicker | TDateTimePicker | The DateTimePicker control to set the value for. |
| value | DateTime | The DateTime value to set. |
Returns: TDateTimePicker. The DateTimePicker control with the updated value.
This method allows for fluent syntax when setting the value of a DateTimePicker control.
var dateTimePicker = new DateTimePicker();
dateTimePicker = dateTimePicker.Value(new DateTime(2023, 10, 1));