BindingManagerDataErrorEventArgs.Exception 屬性

定義

取得在引發 Exception 事件的繫結處理序中所攔截到的 DataError

public:
 property Exception ^ Exception { Exception ^ get(); };
public Exception Exception { get; }
member this.Exception : Exception
Public ReadOnly Property Exception As Exception

屬性值

引發 Exception 事件的 DataError

範例

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

若要執行範例程式碼,請將它貼入包含繼承自 BindingManagerBase 之型別實例的專案,例如 PropertyManagerCurrencyManager 。 然後命名 實例 BindingManagerBase1 ,並確定事件處理常式與 事件相關聯 BindingManagerBase.DataError

private void BindingManagerBase1_DataError(Object sender, BindingManagerDataErrorEventArgs e) {
    System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
    messageBoxCS.AppendFormat("{0} = {1}", "Exception", e.Exception);
    messageBoxCS.AppendLine();
    MessageBox.Show(messageBoxCS.ToString(), "DataError Event");
}
Private Sub BindingManagerBase1_DataError(sender as Object, e as BindingManagerDataErrorEventArgs) _ 
     Handles BindingManagerBase1.DataError

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "Exception", e.Exception)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"DataError Event")

End Sub

適用於