Watermark in Windows Forms DateTimePicker (SfDateTimeEdit)

18 Nov 20182 minutes to read

The SfDateTimeEdit control allows you to set the Value to null in the default mode of the DateTimeEditingMode. The watermark can be shown on null value.

Null value

The SfDateTimeEdit control accepts null values only when the DateTimeEditingMode is default. The null value support in the SfDateTimeEdit control can be enabled by setting the AllowNull property to true. If the value is null and the editing text box is empty then the Watermark will be displayed as the text in the SfDateTimeEdit control.

using Syncfusion.WinForms.Input;

SfDateTimeEdit dateTimeEdit = new SfDateTimeEdit();

this.Controls.Add(dateTimeEdit);

dateTimeEdit.AllowNull = true;

dateTimeEdit.Value = null;
Imports Syncfusion.WinForms.Input

Dim dateTimeEdit As SfDateTimeEdit = New SfDateTimeEdit

Me.Controls.Add(dateTimeEdit)

dateTimeEdit.AllowNull = true

dateTimeEdit.Value = Nothing

display null value

Change watermark

The watermark is help content that displays in the SfDateTimeEdit control when the AllowNull property is true and the Value property is set to null. The Watermark text will be displayed only when the control loses its focus. The content of the watermark text can be assigned by setting the Watermark of the SfDateTimeEdit.

using Syncfusion.WinForms.Input;

Syncfusion.WinForms.Input.SfDateTimeEdit dateTimeEdit = new Syncfusion.WinForms.Input.SfDateTimeEdit();

this.Controls.Add(dateTimeEdit);

dateTimeEdit.AllowNull = true;

dateTimeEdit.Value = null;

dateTimeEdit.Watermark = "Choose a date";
Imports Syncfusion.WinForms.Input

Dim dateTimeEdit As Syncfusion.WinForms.Input.SfDateTimeEdit = New Syncfusion.WinForms.Input.SfDateTimeEdit

Me.Controls.Add(dateTimeEdit)

dateTimeEdit.AllowNull = true

dateTimeEdit.Value = Nothing

dateTimeEdit.Watermark = "Choose a date"

Watermark support