HeaderPane
Main
Hide
Share Link
Print

TextParsingEventArgs Class

Provides data for the SftDate.TextParsing event, raised before a text typed or pasted by the user is parsed.

An event handler that understands the text (for example "+7" or "next friday") sets Value and Handled. Setting Handled with a null Value rejects the text.

Namespace: Softelvdm.SftDateNET
Assembly: Softelvdm.SftDateNET

Inheritance

Syntax

public class TextParsingEventArgs : System.EventArgs;
Public Class TextParsingEventArgs
    Inherits System.EventArgs

Constructors

This class cannot be instantiated.

Properties

PublicCurrentValueReturns the value before the text was entered.
PublicHandledDefines whether the event handler parsed the text.
PublicTextReturns the text to parse.
PublicValueDefines the value the text represents.

Fields

PublicStaticInherited from System.EventArgsEmptyProvides a value to use with events that do not have event data.

Methods

PublicInherited from System.ObjectEqualsDetermines whether the specified object is equal to the current object.
ProtectedInherited from System.ObjectFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
PublicInherited from System.ObjectGetHashCodeServes as the default hash function.
PublicInherited from System.ObjectGetTypeGets the Type of the current instance.
ProtectedInherited from System.ObjectMemberwiseCloneCreates a shallow copy of the current Object.
PublicStaticInherited from System.ObjectReferenceEqualsDetermines whether the specified Object instances are the same instance.
PublicInherited from System.ObjectToStringReturns a string that represents the current object.

Examples

C# View entire sample code

        }

        private void sftDate1_KeyDown(object sender, KeyEventArgs e) {
            DumpValues("sftDate1.KeyDown", e);
        }

        // sftDate2 - a free-form field; besides dates in the culture's format it accepts +n and -n days from today

        private void sftDate2_TextParsing(object sender, TextParsingEventArgs e) {
            Match m = Regex.Match(e.Text.Trim(), @"^([+-])\s*(\d{1,4})$");
            if (m.Success) {
                int days = int.Parse(m.Groups[2].Value);
                e.Value = DateTime.Today.AddDays(m.Groups[1].Value == "-" ? -days : days);
                e.Handled = true;
            }
            DumpValues("sftDate2.TextParsing", e);

VB.NET View entire sample code

    End Sub

    Private Sub SftDate1_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) Handles SftDate1.KeyDown
        DumpValues("SftDate1.KeyDown", e)
    End Sub

    ' SftDate2 - a free-form field; besides dates in the culture's format it accepts +n and -n days from today

    Private Sub SftDate2_TextParsing(ByVal sender As Object, ByVal e As TextParsingEventArgs) Handles SftDate2.TextParsing
        Dim m As Match = Regex.Match(e.Text.Trim(), "^([+-])\s*(\d{1,4})$")
        If m.Success Then
            Dim days As Integer = Integer.Parse(m.Groups(2).Value)
            e.Value = DateTime.Today.AddDays(If(m.Groups(1).Value = "-", -days, days))
            e.Handled = True
        End If
        DumpValues("SftDate2.TextParsing", e)

See Also Classes | SftDate/NET 3.0