HeaderPane
Main
Hide
Share Link
Print

TextParsing Event, SftDate Object

Typed or pasted text is about to be parsed.

Syntax

C#void object_TextParsing(object sender, AxSftDateLib20._ISftDateEvents_TextParsingEvent e);
VB.NETPrivate Sub object_TextParsing(ByVal sender As Object, ByVal e As AxSftDateLib20._ISftDateEvents_TextParsingEvent) Handles object.TextParsing
C++void OnTextParsingobject(BSTR Text, VARIANT Current, VARIANT_BOOL* Handled, VARIANT* Value);
CHRESULT OnTextParsingobject(BSTR Text, VARIANT Current, VARIANT_BOOL* Handled, VARIANT* Value);

object

A SftDate object.

Text

The text typed or pasted. In range selection mode, the text of one of the two dates.

Current

The current value (or date of the range) the text replaces, for texts relative to it. Null if there is none.

Handled

Set to True if the application parsed the text.

Value

The parsed value. Null together with Handled rejects the text.

Comments

The TextParsing event occurs when the date field control parses a text: the text typed in free-form editing (EditStyle), a value pasted from the clipboard and the text set using the Text property. p If the application leaves Handled False, the control parses the text itself: in the format of the field, then leniently in the formats of the culture, and the texts "=Today", "=Yesterday", "=Tomorrow" and "=Now". A value the application or the control parsed is then validated (ValueValidating), except for the Text property. p Example: "+3" is three days from today. pre private void fieldDueDate_TextParsing(object sender, AxSftDateLib20._ISftDateEvents_TextParsingEvent e) { int days; if ((e.text.StartsWith("+") || e.text.StartsWith("-")) && int.TryParse(e.text, out days)) { e.value = DateTime.Today.AddDays(days); e.handled = true; } } end

Examples

C# View entire sample code

        }

        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));
        }

        private void field_DropDownOpening(object sender, _ISftDateEvents_DropDownOpeningEvent e) {
            // e.cancel = true would keep the dropdown closed
            LogEvent(sender, "DropDownOpening", "Cancel=" + e.cancel);
        }

VB.NET View entire sample code

        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.
    Private Sub fieldDueDate_TextParsing(sender As Object, e As _ISftDateEvents_TextParsingEvent) Handles fieldDueDate.TextParsing
        Dim m As Match = Regex.Match(e.text, "^\s*([+-])\s*(\d{1,4})\s*$")
        If m.Success Then
            Dim days As Integer = Integer.Parse(m.Groups(2).Value) * If(m.Groups(1).Value = "-", -1, 1)
            e.value = Date.Today.AddDays(days)
            e.handled = True
        End If
        field_TextParsing(sender, e)

C++ View entire sample code

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)
    ON_EVENT_RANGE(CMainDlg, IDC_APPOINTMENT, IDC_CALENDAR, 12 /* TodayClicked */, OnTodayClicked, VTS_I4)

See Also SftDate Object | Object Hierarchy | Editing


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