ComponentOne CalendarView for WinForms
CalendarView for WinForms / Using Controls / DateEdit Features / Null Value and Watermark Support
In This Topic
    Null Value and Watermark Support
    In This Topic

    Null values can be difficult to handle without appropriate rules or settings. However, DateEdit provides flexible rules for handling null values and controlling relevant aspects in a variety of cases.

    In ReadOnly mode

    The DateEdit control allows displaying null values through the NullText property of DisplayFormat when the control is in ReadOnly mode. It is possible to override the NullText property in DisplayFormat to display watermark in the DateEdit control.

    In edit mode

    This is default mode of DateEditor. In edit mode (when ReadOnly is false), DateEdit allows displaying null values by setting the NullText property of EditFormat.

    In both modes, it is possible to display empty strings by setting the EmptyAsNull property to true. When editing date time values in DateEdit with DateTimeInput set to true, the control appears empty representing the null value. As you start editing values in control, the control turns to the last non-null value assigned to it or today’s date.

    The following image shows DateEdit displaying null text (watermark) in the ReadOnly mode.

    The following code snippet shows how to show null text in DateEdit in ReadOnly mode.

    ' set calendar pop-up as ReadOnly
    C1DateEdit1.[ReadOnly] = True
    ' display null text in DateEdit
    C1DateEdit1.DisplayFormat.NullText = "No data is selected"
    //set calendar pop-up as ReadOnly
    //c1DateEdit1.ReadOnly = true;
    // display null text in DateEdit
    //c1DateEdit1.DisplayFormat.NullText = "No data is selected";
    See Also