DataRepeaterDataErrorEventArgs.Control 属性

获取引发数据错误的 Control

命名空间:  Microsoft.VisualBasic.PowerPacks
程序集:  Microsoft.VisualBasic.PowerPacks.Vs(在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)

语法

声明
Public ReadOnly Property Control As Control
public Control Control { get; }
public:
property Control^ Control {
    Control^ get ();
}
member Control : Control
function get Control () : Control

属性值

类型:System.Windows.Forms.Control
引发此错误的控件。

备注

DataError 事件使您能够在数据操作过程中,代码引发由 DataRepeater 控件调用的异常。

Control 属性包含在发生错误的 DataRepeaterItem 的控件。

示例

数据,则错误时,下面的示例演示如何使用从 DataRepeaterDataErrorEventArgs 的数据显示消息。

Private Sub DataRepeater1_DataError(
    ByVal sender As Object, 
    ByVal e As Microsoft.VisualBasic.PowerPacks.DataRepeaterDataErrorEventArgs
  ) Handles DataRepeater1.DataError

    Dim ErrorMsg As String
    ' Create an error string.
    ErrorMsg = "Invalid value entered for " & e.Control.Name & ". "
    ErrorMsg = ErrorMsg & e.Exception.Message
    ' Display the error to the user.
    MsgBox(ErrorMsg)
    ' Do not raise an exception.
    e.ThrowException = False
End Sub
private void dataRepeater1_DataError(object sender, 
    Microsoft.VisualBasic.PowerPacks.DataRepeaterDataErrorEventArgs e)
{
    string ErrorMsg;
    // Create an error string.
    ErrorMsg = "Invalid value entered for " + e.Control.Name + ". ";
    ErrorMsg = ErrorMsg + e.Exception.Message;
    // Display the error to the user.
    MessageBox.Show(ErrorMsg);
    // Do not raise an exception.
    e.ThrowException = false;
}

.NET Framework 安全性

请参见

参考

DataRepeaterDataErrorEventArgs 类

Microsoft.VisualBasic.PowerPacks 命名空间

DataError

其他资源

DataRepeater 控件简介 (Visual Studio)