首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

請教:怎么取代系統錯誤ExceptionMessage

2012-03-05 
請教:如何取代系統錯誤ExceptionMessage?RT,我設置Datagridview為數值格式,輸入非法字符時系統會提示錯誤,

請教:如何取代系統錯誤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( "你输入的格式不正确,必须为数字! ");
}

热点排行