XmlMappedRange.Validation 属性

获取 Microsoft.Office.Interop.Excel.Validation 对象,该对象表示 XmlMappedRange 控件的数据验证。

命名空间:  Microsoft.Office.Tools.Excel
程序集:  Microsoft.Office.Tools.Excel(在 Microsoft.Office.Tools.Excel.dll 中)

语法

声明
ReadOnly Property Validation As Validation
Validation Validation { get; }

属性值

类型:Microsoft.Office.Interop.Excel.Validation
Microsoft.Office.Interop.Excel.Validation 对象,表示 XmlMappedRange 控件的数据验证。

示例

下面的代码示例使用 Validation 属性在输入 XmlMappedRange 中的字符小于三个字符时显示一个验证错误。此代码示例假定当前工作表包含一个名为 CustomerLastNameCell 的 XmlMappedRange

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 安全性

请参见

参考

XmlMappedRange 接口

Microsoft.Office.Tools.Excel 命名空间