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

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

    ---------------------------
    “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)
    {

      //可以不执行代码哦

    }

  • 相关阅读:
    Java时间和时间戳的相互转换
    linux 通过pid 寻找程序路径的最简单命令(pwdx)
    Oracle--存储过程学习进阶
    经典sql总结(2)
    经典sql总结(1)
    类的初始化
    StringBuffer和String 的例子
    i=i++
    一个异常学习的好例子
    有空研究这篇http://blog.csdn.net/studyvcmfc/article/details/7720258 研究后写篇记录
  • 原文地址:https://www.cnblogs.com/haibing0107/p/7614644.html
Copyright © 2011-2022 走看看