读书人

教:怎么取代系ExceptionMess

发布时间: 2012-03-05 11:54:02 作者: rapoo

教:如何取代系ExceptionMessage?
RT,我置Datagridview值格式,入非法字符系提示,如何取代系息,自定息呢?

[解决办法]
try catch 后throw自己定义的Exception
[解决办法]
try
{
//your code
}
catch(Exception err)
{
throw new Exception( "YourErr ");
}
[解决办法]
楼上的都说了。
[解决办法]
在DataError事件中写
private void Datagridview_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
if (e.ColumnIndex == 4)
Utility.ShowInformation( "你输入的格式不正确,必须为数字! ");
if (e.ColumnIndex == 5)
Utility.ShowInformation( "你输入的格式不正确,必须为数字! ");
if (e.ColumnIndex == 6)
Utility.ShowInformation( "你输入的格式不正确,必须为数字! ");
if (e.ColumnIndex == 7)
Utility.ShowInformation( "你输入的格式不正确,必须为数字! ");
}

读书人网 >C#

热点推荐