如何处理 Ultrawingrid (winforms) 底层数据集的异常
我有一个 UltraWinGrid,其后面有一个数据集。在数据表的 Row_Changing 事件处理程序中,我对数据进行一些检查,如果数据无效则抛出异常。我想在我的应用程序中显示此异常的消息。然而,UltraGrid 似乎捕获了异常并显示它自己的带有异常的消息框。如何防止显示消息框并在应用程序中捕获该错误?
private static void Row_Changing( object sender, DataRowChangeEventArgs e )
{
if( <some logic to test the row values>)
throw new Exception("you can't do that");
}
I have an UltraWinGrid with a dataset behind it. In the datatable's Row_Changing event handler, I do some checking of the data and throw an exception if it is invalid. I want to display a message for this exception within my application. However, the UltraGrid seems to catch the exception and display it's own message box with the exception. How can I prevent the message box from being displayed, and catch that error within my application?
private static void Row_Changing( object sender, DataRowChangeEventArgs e )
{
if( <some logic to test the row values>)
throw new Exception("you can't do that");
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我解决了,但我想无论如何我都会提出这个问题(因为我已经把它打出来了)。
您需要处理UltraGrid的Error事件并将e.Cancel设置为true以防止弹出对话框:
I worked it out, but I thought I'd create this question anyway (since I have already typed it out).
You need to handle the Error event of the UltraGrid and set e.Cancel to true to prevent the dialog box from popping up: