DataRepeaterDataErrorEventArgs.ThrowException 属性
获取或设置一个在代码执行后引发异常退出 DataError 事件处理程序的值。
命名空间: Microsoft.VisualBasic.PowerPacks
程序集: Microsoft.VisualBasic.PowerPacks.Vs(在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)
语法
声明
Public Property ThrowException As Boolean
public bool ThrowException { get; set; }
public:
property bool ThrowException {
bool get ();
void set (bool value);
}
member ThrowException : bool with get, set
function get ThrowException () : boolean
function set ThrowException (value : boolean)
属性值
类型:System.Boolean
true ,如果引发异常;否则, false。默认值为 false。
备注
DataError 事件使您能够在数据操作过程中,代码引发由 DataRepeater 控件调用的异常。
,如果用户,未更正数据错误 ThrowException 属性可用于引发 Exception 。
示例
数据,则错误时,下面的示例演示如何使用从 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 命名空间