码迷,mamicode.com
首页 > Windows程序 > 详细

DataGridView 中发生以下异常: System.Exception: 是 不是 Decimal 的有效值。 ---> System.FormatException: 输入字符串的格式不正确。

时间:2017-09-30 15:05:52      阅读:797      评论:0      收藏:0      [点我收藏+]

标签:windows   ati   测试的   contex   class   对话框   style   datagrid   option   

其实之前我自己是没测出这个问题的,但是一放到测试的手上就出来了,原因我知道在哪里改输什么东西,但是人家不知道啊。报错如下:

技术分享

 

 

 

---------------------------
“DataGridView 默认错误”对话框
---------------------------
DataGridView 中发生以下异常:

System.Exception: 是 不是 Decimal 的有效值。 ---> System.FormatException: 输入字符串的格式不正确。
   在 System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   在 System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt)
   在 System.ComponentModel.DecimalConverter.FromString(String value, NumberFormatInfo formatInfo)
   在 System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   --- 内部异常堆栈跟踪的结尾 ---
   在 System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   在 System.ComponentModel.TypeConverter.ConvertFrom(Object value)
   在 System.Windows.Forms.DataGridView.DataGridViewDataConnection.PushValue(Int32 boundColumnIndex, Int32 columnIndex, Int32 rowIndex, Object value)

要替换此默认对话框,请处理 DataError 事件。
---------------------------
确定   
---------------------------

解决方法,注册一个DGV_DataError事件就可以。

private void DGV_DataError(object sender, DataGridViewDataErrorEventArgs e)
{

  //可以不执行代码哦

}

 

DataGridView 中发生以下异常: System.Exception: 是 不是 Decimal 的有效值。 ---> System.FormatException: 输入字符串的格式不正确。

标签:windows   ati   测试的   contex   class   对话框   style   datagrid   option   

原文地址:http://www.cnblogs.com/haibing0107/p/7614644.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!