Telerik UI for WinForms


The significant properties for RadDateTimePicker are:

  • Value: This is the date selected from the picker and can be set in code or from the drop down calendar in the Properties window.
    [C#] Setting the value of RadDateTimePicker Copy imageCopy
    this.radDateTimePicker1.Value = DateTime.Today.AddDays(1);
    [VB.NET] Setting the value of RadDateTimePicker Copy imageCopy
    Me.RadDateTimePicker1.Value = DateTime.Now.AddDays(1)
  • MinDate, MaxDate: These two dates form the bounds that dates can be selected from in the picker. Attempts to select outside these bounds are ignored. The example below sets the MinDate to be the first day of the current month.
    [C#] Setting the MinDate property of RadDateTimePicker Copy imageCopy
    this.radDateTimePicker1.MinDate = DateTime.Today.AddDays(-DateTime.Today.Day);
    [VB.NET] Setting the MinDate property of RadDateTimePicker Copy imageCopy
    Me.RadDateTimePicker1.MinDate = DateTime.Today.AddDays(-DateTime.Today.Day)
  • NullText: This property defines the text that will be displayed in RadDateTimePicker when the NullableValue property is set to null and RadDateTimePicker is not in focus. By default, NullText is an empty string.
    [C#] Setting the NullText property of RadDateTimePicker Copy imageCopy
    this.radDateTimePicker1.NullText = "No date selected";
    [VB.NET] Setting the NullText property of RadDateTimePicker Copy imageCopy
    Me.RadDateTimePicker1.NullText = "No date selected"
  • ShowTimePicker: this properties determines the display of TimePicker in popup element of RadDateTimePicker.
    [C#] Copy imageCopy
    this.radDateTimePicker1.DateTimePickerElement.ShowTimePicker = true;
    [VB.NET] Copy imageCopy
    Me.radDateTimePicker1.DateTimePickerElement.ShowTimePicker = True
  • Format: The DateTimePickerFormat enumeration values are Long, Short, Time and Custom. Set Format to Custom to enable the CustomFormat property.
  • CustomFormat: A format string that determines the display of the date in the picker edit. See the Internationalization and Date Formats topic for more information.
  • Culture determines the language that the drop down calendar and edit will display in.  See the Internationalization and Date Formats topic for more information.
  • ThemeName sets the overall look of the control. Choose from a list of predefined themes or create your own using the Visual Style Builder available from the RadDateTimePicker Smart Tag.
  • CalendarSize gets or sets the size of the RadCalendar in the RadDateTimePicker drop-down.
  • NullableValue is same as the Value property, but the NullableValue property is of type Nullable DateTime. It can be null – in this case if RadDateTimePicker is not selected it will show its NullText. In case RadDateTimePicker is selected, it will show the last entered date – this allows the end-user to enter and edit the date.
    [C#] Setting the NullableValue property of RadDateTimePicker Copy imageCopy
    this.radDateTimePicker1.NullableValue = null;
    [VB.NET] Setting the NullableValue property of RadDateTimePicker Copy imageCopy
    Me.RadDateTimePicker1.NullableValue = Nothing

    Simple databinding

    NullableValue can be bound to a business object that exposes a property of type nullable DateTime. The code below demonstrates how to do this:

    [C#] Copy imageCopy
    public class MyObject
        public MyObject(DateTime? _endTime)
            this._endTime = _endTime;
        private DateTime? _endTime;
        public DateTime? EndTime
            get { return _endTime; }
            set { _endTime = value; }
    private BindingList<MyObject> myList;
    protected override void OnLoad(EventArgs e)
        myList = new BindingList<MyObject>();
        myList.Add(new MyObject(null));
        myList.Add(new MyObject(DateTime.Now));
        myList.RaiseListChangedEvents = true;
        this.radDateTimePicker1.DataBindings.Add(new Binding("NullableValue", this.myList, "EndTime", true, DataSourceUpdateMode.OnPropertyChanged));
    [VB.NET] Copy imageCopy
    Public Class MyObject
        Public Sub New(ByVal _endTime? As Date)
            Me._endTime = _endTime
        End Sub
        Private _endTime? As Date
        Public Property EndTime() As Date?
                Return _endTime
            End Get
            Set(ByVal value? As Date)
                _endTime = value
            End Set
        End Property
    End Class
    Private myList As BindingList(Of MyObject)
    Protected Overrides Sub OnLoad(ByVal e As EventArgs)
        myList = New BindingList(Of MyObject)()
        myList.Add(New MyObject(Nothing))
        myList.Add(New MyObject(Date.Now))
        myList.RaiseListChangedEvents = True
        Me.RadDateTimePicker1.DataBindings.Add(New Binding("NullableValue", Me.myList, "EndTime", True, DataSourceUpdateMode.OnPropertyChanged))
    End Sub
  • Editing Date and Time in RadDateTimePicker.

    To use RadDateTimePicker as date and time editor you need to enable embedded TimePicker and set the desired mask that shows the time parts.

    [C#] Copy imageCopy
    this.radDateTimePicker1.DateTimePickerElement.ShowTimePicker = true;
    this.radDateTimePicker1.Format = DateTimePickerFormat.Custom;
    this.radDateTimePicker1.CustomFormat = "MMM - dd - yyyy hh:mm tt";
    (this.radDateTimePicker1.DateTimePickerElement.CurrentBehavior as RadDateTimePickerCalendar).DropDownMinSize = new System.Drawing.Size(330, 250);
    [VB.NET] Copy imageCopy
    Me.radDateTimePicker1.DateTimePickerElement.ShowTimePicker = True
    Me.radDateTimePicker1.Format = DateTimePickerFormat.[Custom]
    Me.radDateTimePicker1.CustomFormat = "MMM - dd - yyyy hh:mm tt"
    TryCast(Me.radDateTimePicker1.DateTimePickerElement.CurrentBehavior, RadDateTimePickerCalendar).DropDownMinSize = New System.Drawing.Size(330, 250)

Accessing the MaskDateTimeProvider

The MaskDateTimeProvider can be accessed by casting to that appropriate class. This provider contains useful properties and methods that can help you to navigate trough the date parts.

  • The AutoSelectNextPartproperty controls whether or not the next date part will be automatically selected when the user types.

  • The SelectedItemIndexproperty can be used to retrieve the current selected part of the date.

  • The SelectFirstItem method just selects the first part of the date.

  • The SelectNextItem method just selects the last part of the date.

The following code spinet demonstrates how one can access and use the provider:

[C#] Copy imageCopy
MaskDateTimeProvider provider = this.radDateTimePicker1.DateTimePickerElement.TextBoxElement.Provider as MaskDateTimeProvider;
provider.AutoSelectNextPart = true;
[VB.NET] Copy imageCopy
Dim provider As MaskDateTimeProvider = TryCast(Me.radDateTimePicker1.DateTimePickerElement.TextBoxElement.Provider, MaskDateTimeProvider)
provider.AutoSelectNextPart = True