Skip to main content
Version: 4.1

DateTimePickerExtensions

Namespace: Wisej.Web.Markup

Assembly: Wisej.Framework (4.1.0.0)

Adds fluent markup extension methods to the DateTimePicker class.

public class DateTimePickerExtensions

Methods

Static member CustomFormat<TDateTimePicker>(dateTimePicker, format)

Sets a custom date and time format string for the specified DateTimePicker control.

ParameterTypeDescription
TDateTimePickerThe type of the date time picker, which must inherit from DateTimePicker.
dateTimePickerTDateTimePickerThe date time picker for which to set the custom format.
formatStringThe 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");

Static member Format<TDateTimePicker>(dateTimePicker, format)

Sets the format for displaying date and time in the specified DateTimePicker control.

ParameterTypeDescription
TDateTimePickerThe type of the date time picker, which must inherit from DateTimePicker.
dateTimePickerTDateTimePickerThe date time picker for which to set the format.
formatDateTimePickerFormatThe 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);

Static member MaxDate<TDateTimePicker>(dateTimePicker, value)

Sets the maximum date and time that can be selected in the specified DateTimePicker.

ParameterTypeDescription
TDateTimePickerThe type of the DateTimePicker.
dateTimePickerTDateTimePickerThe DateTimePicker to set the maximum date for.
valueDateTimeThe 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));

Static member MinDate<TDateTimePicker>(dateTimePicker, value)

Sets the minimum date and time that can be selected in the specified DateTimePicker.

ParameterTypeDescription
TDateTimePickerThe type of the DateTimePicker.
dateTimePickerTDateTimePickerThe DateTimePicker to set the minimum date for.
valueDateTimeThe 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));

Static member OnValueChanged<TDateTimePicker>(dateTimePicker, action)

Attaches an event handler to the ValueChanged event.

ParameterTypeDescription
TDateTimePickerThe type of the DateTimePicker.
dateTimePickerTDateTimePickerThe DateTimePicker to attach the event handler to.
actionAction<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));

Static member Value<TDateTimePicker>(dateTimePicker, value)

Sets the value of the specified DateTimePicker control and returns the control.

ParameterTypeDescription
TDateTimePickerThe type of the DateTimePicker control.
dateTimePickerTDateTimePickerThe DateTimePicker control to set the value for.
valueDateTimeThe 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));