Partilhar via


XmlMappedRange.Validation Property

Gets the Microsoft.Office.Interop.Excel.Validation object that represents data validation for the XmlMappedRange control.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

Syntax

'Declaration
ReadOnly Property Validation As Validation
Validation Validation { get; }

Property Value

Type: Microsoft.Office.Interop.Excel.Validation
The Microsoft.Office.Interop.Excel.Validation object that represents data validation for the XmlMappedRange control.

Examples

The following code example uses the Validation property to display a validation error if fewer than three characters are entered into an XmlMappedRange. This code example assumes that the current worksheet contains an XmlMappedRange named CustomerLastNameCell.

Private Sub SetValidation()
    Me.CustomerLastNameCell.Validation.Add( _
        Excel.XlDVType.xlValidateTextLength, _
        Excel.XlDVAlertStyle.xlValidAlertInformation, _
        Excel.XlFormatConditionOperator.xlGreaterEqual, 3)

    Me.CustomerLastNameCell.Validation.ErrorMessage = _
        "You must enter a name with three or more letters." 
End Sub
private void SetValidation()
{
    this.CustomerLastNameCell.Validation.Add(
        Excel.XlDVType.xlValidateTextLength, 
        Excel.XlDVAlertStyle.xlValidAlertInformation,
        Excel.XlFormatConditionOperator.xlGreaterEqual, 3);

    this.CustomerLastNameCell.Validation.ErrorMessage = 
        "You must enter a name with three or more letters.";
}

.NET Framework Security

See Also

Reference

XmlMappedRange Interface

Microsoft.Office.Tools.Excel Namespace