BindingCompleteEventArgs.ErrorText 屬性

定義

取得在繫結作業期間所發生的錯誤之文字描述。

public:
 property System::String ^ ErrorText { System::String ^ get(); };
public string ErrorText { get; }
member this.ErrorText : string
Public ReadOnly Property ErrorText As String

屬性值

在繫結作業期間所發生的錯誤之文字描述。

範例

下列程式碼範例示範如何使用這個成員。 在此範例中,事件處理常式會報告事件的發生次數 Binding.BindingComplete 。 此報告可協助您瞭解事件發生的時間,並可協助您進行偵錯。 若要報告多個事件或經常發生的事件,請考慮將 取代 MessageBox.ShowConsole.WriteLine 或將訊息附加至多行 TextBox

若要執行範例程式碼,請將它貼入包含名為 Binding1 之類型 Binding 實例的專案。 然後,確定事件處理常式與 事件相關聯 Binding.BindingComplete

private void Binding1_BindingComplete(Object sender, BindingCompleteEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "Binding", e.Binding );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "BindingCompleteState", e.BindingCompleteState );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "BindingCompleteContext", e.BindingCompleteContext );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ErrorText", e.ErrorText );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Exception", e.Exception );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Cancel", e.Cancel );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "BindingComplete Event" );
}
Private Sub Binding1_BindingComplete(sender as Object, e as BindingCompleteEventArgs) _ 
     Handles Binding1.BindingComplete

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "Binding", e.Binding)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "BindingCompleteState", e.BindingCompleteState)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "BindingCompleteContext", e.BindingCompleteContext)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "ErrorText", e.ErrorText)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Exception", e.Exception)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Cancel", e.Cancel)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"BindingComplete Event")

End Sub

備註

如果系結作業中沒有發生任何錯誤,這個屬性會傳回空字串。 當發生例外狀況時,它會傳回 屬性的值 Exception.Message

適用於