HeaderPane
Main
Hide
Share Link
Print

ValueValidating Event, SftDate Class

Occurs before a value entered by the user is accepted.

Class: SftDate
Namespace: Softelvdm.SftDateNET
Assembly: Softelvdm.SftDateNET

Syntax

public event ValueValidatingEventHandler ValueValidating;
Public Event ValueValidating As ValueValidatingEventHandler

Comments

Occurs before a value entered by the user is accepted.

Examples

C# View entire sample code

            fLastEventDup = false;
        }

        // sftDate1 - a date and time field; appointments are only accepted on weekdays

        private void sftDate1_ValueValidating(object sender, ValueValidatingEventArgs e) {
            if (e.NewValue.HasValue && (e.NewValue.Value.DayOfWeek == DayOfWeek.Saturday || e.NewValue.Value.DayOfWeek == DayOfWeek.Sunday)) {
                e.Cancel = true;
                DumpValues("sftDate1.ValueValidating (canceled, a weekend)", e);
            } else
                DumpValues("sftDate1.ValueValidating", e);
        }

        private void sftDate1_ValueChanged(object sender, EventArgs e) {
            DumpValues("sftDate1.ValueChanged (" + sftDate1.Text + ")", e);
        }

VB.NET View entire sample code

    Private Sub ButtonClear_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ButtonClear.Click
        ListView1.Items.Clear()
        strLastEvent = ""
        fLastEventDup = False
    End Sub

    ' SftDate1 - a date and time field; appointments are only accepted on weekdays

    Private Sub SftDate1_ValueValidating(ByVal sender As Object, ByVal e As ValueValidatingEventArgs) Handles SftDate1.ValueValidating
        If e.NewValue.HasValue AndAlso (e.NewValue.Value.DayOfWeek = DayOfWeek.Saturday OrElse e.NewValue.Value.DayOfWeek = DayOfWeek.Sunday) Then
            e.Cancel = True
            DumpValues("SftDate1.ValueValidating (canceled, a weekend)", e)
        Else
            DumpValues("SftDate1.ValueValidating", e)
        End If
    End Sub

See Also SftDate Class | Classes | SftDate/NET 3.0