Determines whether the contents are valid.
Get
| C# | bool Boolean = object.Valid; |
| VB.NET | Boolean = object.Valid As Boolean |
| C++ | VARIANT_BOOL Boolean = object->Valid; VARIANT_BOOL Boolean = object->GetValid(); |
| C | HRESULT object->get_Valid(VARIANT_BOOL* Boolean); |
object
Boolean
Determines whether the contents are valid.
| Boolean | Description |
|---|---|
| True | The control's contents are valid. |
| False | The control's contents are not valid. |
The Valid property determines whether the contents are valid.
The AllowEmpty property defines whether the contents are optional (valid even if empty).
If the control contents don't match the defined mask (see Mask property), the ValidationError event occurs.
If the control contents are valid and match the defined mask (see Mask property), the CustomValidation event is invoked.
The Contents.ValidMsg property can also be used to determine whether the contents are valid and automatically displays an error message.
axSftMask1.Alignment = SftMaskAlignConstants.alignSftMaskLeft;
axSftMask1.BackColorInvalid = Color.Red;
axSftMask1.ForeColorInvalid = Color.White;
axSftMask1.FormattedText = "Please enter a telephone number";
}
private void axSftMask1_Change(object sender, System.EventArgs e)
{
if (axSftMask1.Contents.Valid) {
MessageBox.Show("This is a valid phone number.");
} else {
if (axSftMask1.Contents.Empty)
axSftMask1.FormattedText = "Please enter a telephone number";
else
axSftMask1.FormattedText = "";
}
AxSftMask1.Mask = "\(###\) ###\-####"
AxSftMask1.Alignment = SftMaskAlignConstants.alignSftMaskLeft
AxSftMask1.BackColorInvalid = Color.Red
AxSftMask1.ForeColorInvalid = Color.White
AxSftMask1.FormattedText = "Please enter a telephone number"
End Sub
Private Sub AxSftMask1_Change(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxSftMask1.Change
If AxSftMask1.Contents.Valid Then
MsgBox("This is a valid phone number.")
Else
If AxSftMask1.Contents.Empty Then
AxSftMask1.FormattedText = "Please enter a telephone number"
Else
AxSftMask1.FormattedText = ""
End If
m_pMask1->ForeColorInvalid = RGB(255,255,255);
m_pMask1->FormattedText = _T("Please enter a telephone number");
return TRUE;
}
void CProject1Dlg::OnChangeSftMask1()
{
if (m_pMask1->Contents->Valid != VARIANT_FALSE) {
AfxMessageBox(_T("This is a valid phone number."));
} else {
if (m_pMask1->Contents->Empty != VARIANT_FALSE)
m_pMask1->FormattedText = _T("Please enter a telephone number");
else
m_pMask1->FormattedText = _T("");
}See Also SftMaskContents Object | Object Hierarchy