Hide

SftMask/OCX 7.0 - ActiveX Masked Edit Control

Display
Print

CustomValidation Event, SftMask Object

Valid input is detected (custom application validation).

Syntax

VB.NETPrivate Sub object_CustomValidation(ByVal sender As Object, ByVal e As EventArgumentType) Handles object.CustomValidation
VBPrivate Sub object_CustomValidation(Cancel As Boolean)
C#.NETvoid object_CustomValidation(object sender, EventArgumentType e);
VC++void OnCustomValidationobject(VARIANT_BOOL* Cancel);
CHRESULT OnCustomValidationobject(VARIANT_BOOL* Cancel);

object

A SftMask object.

Cancel

A Boolean value. If True is returned, the contents are considered invalid and the ValidationError event occurs. If False is returned, the contents are considered valid. The default is False.

Comments

The CustomValidation event occurs when valid input is detected (custom application validation).

The CustomValidation event occurs whenever the control loses the input focus or the Contents.ValidMsg and ValidMsg properties are used and the contents are valid (based on the Mask property).

This event allows the application to implement additional data validation, beyond the validation offered by the Mask property.

If the current input in the Masked Edit control is considered valid (based on the Mask property), the CustomValidation event occurs. The application can perform further validation and accept or reject the current contents.

Even though the contents are always considered valid in a simple edit control, the CustomValidation event still occurs.

Examples

VB.NET

            axSftMaskAmount.Contents.Valid Then
        ' save the data
        Application.Exit() '  and exit
    Else
        MessageBox.Show("There are validation errors - Please correct the data entered.")
    End If
End Sub

Private Sub axSftMaskZIP_CustomValidation(ByVal sender As Object, ByVal e As AxSftMaskLib70._ISftMaskEvents_CustomValidationEvent) Handles axSftMaskZIP.CustomValidation
    If axSftMaskZIP.Text <> "11111" Then
        e.cancel = True
    End If
End Sub

VB6

            SftMaskAmount.Contents.Valid Then
        ' save the data
        End ' and exit
    Else
        MsgBox ("There are validation errors - Please correct the data entered.")
    End If
End Sub

Private Sub SftMaskZIP_CustomValidation(Cancel As Boolean)
    'To demonstrate custom validation, this sample application only accepts the ZIP Code 11111.
    If SftMaskZIP.Text <> "11111" Then
        Cancel = True
    End If
End Sub

C#

            axSftMaskAmount.Contents.Valid) {
        // save the data
        Application.Exit(); //  and exit
    } else {
        MessageBox.Show("There are validation errors - Please correct the data entered.");
    }
}

private void axSftMaskZIP_CustomValidation(object sender, AxSftMaskLib70._ISftMaskEvents_CustomValidationEvent e)
{
    if (axSftMaskZIP.Text != "11111") {
        e.cancel = true;
    }
}

C++

    m_vSftMaskTelephone = m_CtlTelephone.GetControlUnknown();
    _ASSERT(m_vSftMaskTelephone != NULL);
    m_vSftMaskAmount = m_CtlAmount.GetControlUnknown();
    _ASSERT(m_vSftMaskAmount != NULL);

    return TRUE;  // return TRUE  unless you set the focus to a control
}

void CSample4Dlg::OnCustomValidationSftMaskZip(BOOL FAR* Cancel)
{
    if (m_vSftMaskZIP->Text != _bstr_t("11111")) {
        *Cancel = TRUE;
    }
}

void CSample4Dlg::OnOK()

See Also SftMask Events | Object Hierarchy


Last Updated 08/13/2020 - (email)
© 2024 Softel vdm, Inc.