共用方式為


BindingManagerBase.DataError 事件

定義

當 a Exception 被 靜默處理 BindingManagerBase時會發生。

public:
 event System::Windows::Forms::BindingManagerDataErrorEventHandler ^ DataError;
public event System.Windows.Forms.BindingManagerDataErrorEventHandler DataError;
member this.DataError : System.Windows.Forms.BindingManagerDataErrorEventHandler 
Public Custom Event DataError As BindingManagerDataErrorEventHandler 

事件類型

範例

以下程式碼範例展示了此成員的使用方式。 在這個例子中,事件處理者會回報事件 DataError 的發生情況。 此報告能幫助您了解事件發生時間,並協助除錯。 若要報告多個事件或頻繁發生的事件,請考慮將MessageBox.Show訊息替換Console.WriteLine為或附加於多行TextBox

要執行範例程式碼,將它貼到包含繼承自 BindingManagerBase的型別實例的專案中,例如 a PropertyManagerCurrencyManager。 接著命名實例 BindingManagerBase1 ,並確保事件處理程序與事件 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

備註

此事件僅提供資訊性,僅報告符合通用語言規範(CLS)的例外情況。 要判斷發生的異常類型,請處理此事件並檢查 的屬性BindingManagerDataErrorEventArgsException

如需處理事件的詳細資訊,請參閱 處理和引發事件

適用於