Aracılığıyla paylaş


XMLNode.SetValidationError Yöntem

Bir kullanıcı için görüntülenen doğrulama hata metni değiştirir bir XMLNode denetlemek ve Microsoft Office Word'ün bir düğümü geçersiz olarak rapor zorlar.

Ad alanı:  Microsoft.Office.Tools.Word
Derleme:  Microsoft.Office.Tools.Word (Microsoft.Office.Tools.Word.dll içinde)

Sözdizimi

'Bildirim
Sub SetValidationError ( _
    Status As WdXMLValidationStatus, _
    ByRef ErrorText As Object, _
    ClearedAutomatically As Boolean _
)
void SetValidationError(
    WdXMLValidationStatus Status,
    ref Object ErrorText,
    bool ClearedAutomatically
)

Parametreler

  • ClearedAutomatically
    Tür: System.Boolean
    true hata iletisi sonraki yakında otomatik olarak temizlemek için belirtilen düğüm üzerinde doğrulama olayı oluşur. false çalışmasını gerektirecek şekilde SetValidationError yöntemi ile bir Status parametresi wdXMLValidationStatusOK özel hata metni temizleyin.

Notlar

Özel hata metnini ayarlamak için wdXMLValidationStatusCustom sabit.

İsteğe bağlı parametreler

İsteğe bağlı parametreler hakkında daha fazla bilgi için bkz: Office Çözümlerinde İsteğe Bağlı Parametreler.

Örnekler

Aşağıdaki kod örneği SetValidationError özel doğrulama hata iletisi için yöntem bir XMLNode.Bir olay işleyicisi ValidationError olay, özel doğrulama hata iletisi görüntülenir XMLNode doğrulama.Bu örnekte, geçerli belge iki içerdiğini kabul XMLNode adlı nesneleri CustomerAddress1Node ve CustomerZipNode bir tamsayı veri türü içeren şema öğeleri eşleştirin.

Private Sub XMLNodeValidationError()

    ' Set custom error message for Address1 element.
    Dim errorText As String = Me.CustomerAddress1Node.BaseName & _
        " element must be an integer."
    Dim objErrorText As Object = CType(errorText, Object)
    Me.CustomerAddress1Node.SetValidationError( _
        Word.WdXMLValidationStatus.wdXMLValidationStatusCustom, _
        objErrorText, False)

    ' This does not raise a validation error.
    Dim val As Integer = 22222
    Me.CustomerZipNode.NodeText = val.ToString()

    ' This raises a validation error.
    Me.CustomerAddress1Node.NodeText = "Seventeen Hundred Twenty One"
End Sub

Private Sub CustomerNode_ValidationError(ByVal sender As Object, _
    ByVal e As EventArgs) Handles CustomerZipNode.ValidationError, _
    CustomerAddress1Node.ValidationError

    Dim tempNode As Microsoft.Office.Tools.Word.XMLNode = CType(sender,  _
        Microsoft.Office.Tools.Word.XMLNode)
    MsgBox("Error: " & tempNode.ValidationErrorText(False))
End Sub
private void XMLNodeValidationError()
{
    // Set custom error message for Address1 element.
    string errorText = this.CustomerAddress1Node.BaseName + 
        " element must be an integer.";
    object objErrorText = (object)errorText;
    this.CustomerAddress1Node.SetValidationError(
        Word.WdXMLValidationStatus.wdXMLValidationStatusCustom,
        ref objErrorText, false);

    // Attach validation event handlers.
    this.CustomerZipNode.ValidationError +=
        new EventHandler(CustomerNode_ValidationError);
    this.CustomerAddress1Node.ValidationError +=
        new EventHandler(CustomerNode_ValidationError);

    // This does not raise a validation error.
    int val = 22222;
    this.CustomerZipNode.NodeText = val.ToString();

    // This raises a validation error.
    this.CustomerAddress1Node.NodeText = 
        "Seventeen Hundred Twenty One";
}

void CustomerNode_ValidationError(object sender, EventArgs e)
{
    Microsoft.Office.Tools.Word.XMLNode tempNode = 
        (Microsoft.Office.Tools.Word.XMLNode)sender;

    MessageBox.Show("Error: " + tempNode.ValidationErrorText[false]);
}

.NET Framework Güvenliği

Ayrıca bkz.

Başvuru

XMLNode Arabirim

Microsoft.Office.Tools.Word Ad Alanı