HeaderPane
Main
Hide
Share Link
Print

ValueValidating Event, SftDate Object

The user changed the value, which can be changed or refused.

Syntax

C#void object_ValueValidating(object sender, AxSftDateLib20._ISftDateEvents_ValueValidatingEvent e);
VB.NETPrivate Sub object_ValueValidating(ByVal sender As Object, ByVal e As AxSftDateLib20._ISftDateEvents_ValueValidatingEvent) Handles object.ValueValidating
C++void OnValueValidatingobject(VARIANT* NewValue, VARIANT* NewRangeEnd, VARIANT_BOOL* Cancel);
CHRESULT OnValueValidatingobject(VARIANT* NewValue, VARIANT* NewRangeEnd, VARIANT_BOOL* Cancel);

object

A SftDate object.

NewValue

The new value, or the first date of the range in range selection mode. Null if the user is emptying the field. The application can replace it.

NewRangeEnd

The new last date of the range, Null for none. The control passes its current last date in single selection mode too. The application can replace it.

Cancel

Set to True to refuse the change and keep the current value.

Comments

The ValueValidating event occurs when the user completes a change of the value: a part typed, a value chosen in the dropdown, free-form text parsed, a value pasted, the field emptied or the Clear button used. Changes made by the application (Value, SetRange, Text) are not validated. p Setting Cancel to True keeps the current value; the field ends the editing and shows the current value again. Otherwise the application can change the value: a new value is moved into the range defined by MinDate and MaxDate, and Null is refused if the field allows neither an empty value nor a check box. The control then raises the ValueChanged event. p An application that refuses a value can tell screen reader users why, using the Announce method.

Examples

C# View entire sample code

            LogEvent(sender, "ValueChanged", "", ((AxSftDate)sender).Text);
        }

        private void field_RangeChanged(object sender, EventArgs e) {
            LogEvent(sender, "RangeChanged");
        }

        private void field_ValueValidating(object sender, _ISftDateEvents_ValueValidatingEvent e) {
            LogEvent(sender, e.cancel ? "ValueValidating (canceled, a weekend)" : "ValueValidating",
                "NewValue=" + FormatDate(e.newValue) + " NewRangeEnd=" + FormatDate(e.newRangeEnd) + " Cancel=" + e.cancel);
        }

        private void field_TextParsing(object sender, _ISftDateEvents_TextParsingEvent e) {
            LogEvent(sender, "TextParsing", "Text=" + e.text + " Current=" + FormatDate(e.current) + " Handled=" + e.handled + " Value=" + FormatDate(e.value));
        }

VB.NET View entire sample code

    Private Sub buttonClear_Click(sender As Object, e As EventArgs) Handles buttonClear.Click
        listEvents.Items.Clear()
        lastEvent = ""
        lastEventDup = False
    End Sub

    ' Appointments are only accepted on weekdays.
    Private Sub fieldAppointment_ValueValidating(sender As Object, e As _ISftDateEvents_ValueValidatingEvent) Handles fieldAppointment.ValueValidating
        If TypeOf e.newValue Is Date Then
            Dim day As DayOfWeek = CDate(e.newValue).DayOfWeek
            If day = DayOfWeek.Saturday OrElse day = DayOfWeek.Sunday Then e.cancel = True
        End If
        field_ValueValidating(sender, e)
    End Sub

    ' Besides dates in the culture's format, the due date accepts +n and -n days from today.

C++ View entire sample code

    ON_BN_CLICKED(IDC_CLEAR, OnClear)
END_MESSAGE_MAP()

// The fields and the calendar share their event dispids, so each event has one handler for all three controls; MFC passes the
// control ID first (the leading VTS_I4).
BEGIN_EVENTSINK_MAP(CMainDlg, CDialog)
    ON_EVENT_RANGE(CMainDlg, IDC_APPOINTMENT, IDC_CALENDAR, 1 /* ValueChanged */, OnValueChanged, VTS_I4)
    ON_EVENT_RANGE(CMainDlg, IDC_APPOINTMENT, IDC_CALENDAR, 2 /* RangeChanged */, OnRangeChanged, VTS_I4)
    ON_EVENT_RANGE(CMainDlg, IDC_APPOINTMENT, IDC_CALENDAR, 3 /* ValueValidating */, OnValueValidating, VTS_I4 VTS_PVARIANT VTS_PVARIANT VTS_PBOOL)
    ON_EVENT_RANGE(CMainDlg, IDC_APPOINTMENT, IDC_CALENDAR, 4 /* TextParsing */, OnTextParsing, VTS_I4 VTS_BSTR VTS_VARIANT VTS_PBOOL VTS_PVARIANT)
    ON_EVENT_RANGE(CMainDlg, IDC_APPOINTMENT, IDC_CALENDAR, 5 /* DropDownOpening */, OnDropDownOpening, VTS_I4 VTS_PBOOL)
    ON_EVENT_RANGE(CMainDlg, IDC_APPOINTMENT, IDC_CALENDAR, 6 /* DropDownOpened */, OnDropDownOpened, VTS_I4)
    ON_EVENT_RANGE(CMainDlg, IDC_APPOINTMENT, IDC_CALENDAR, 7 /* DropDownClosed */, OnDropDownClosed, VTS_I4)
    ON_EVENT_RANGE(CMainDlg, IDC_APPOINTMENT, IDC_CALENDAR, 9 /* DateActivated */, OnDateActivated, VTS_I4 VTS_DATE)
    ON_EVENT_RANGE(CMainDlg, IDC_APPOINTMENT, IDC_CALENDAR, 10 /* ViewChanged */, OnViewChanged, VTS_I4)
    ON_EVENT_RANGE(CMainDlg, IDC_APPOINTMENT, IDC_CALENDAR, 11 /* DisplayChanged */, OnDisplayChanged, VTS_I4)

See Also SftDate Object | Object Hierarchy | Validation


Last Updated 11/29/2026 - (email)
© 2026 Softel vdm, Inc.