Rémy Kaloustian Rémy Kaloustian - 1 year ago 134
C# Question

Check if DatePicker value is null

I would like to check if the value of a

is null (== no date in the box).

By default the
of my
is set to something like
Select a date
, so I can't use the
property to check.

Answer Source

The DatePicker class has a property, SelectedDate, which enable you to get or set the selected date. If there is none selected, it means its value will be null.

if (datePicker.SelectedDate == null)
    // Do what you have to do

Usage of the SelectedDate property

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download