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.Show訊息替換Console.WriteLine為或附加於多行TextBox

要執行範例程式碼,將它貼到包含繼承自 BindingManagerBase的型別實例的專案中,例如 a 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

適用於