在Winform  DatatGridView 控件中绑定了一个模型的属性,结果在生成窗口时,发生错误,异常信息如下 :

Column cannot be added because its CellType property is null.

at System.Windows.Forms.DataGridView.OnAddingColumn(DataGridViewColumn dataGridViewColumn)
at System.Windows.Forms.DataGridViewColumnCollection.Add(DataGridViewColumn dataGridViewColumn)
at System.Windows.Forms.DataGridView.CorrectColumnFrozenStates(DataGridViewColumn[] dataGridViewColumns)
at System.Windows.Forms.DataGridView.OnAddingColumns(DataGridViewColumn[] dataGridViewColumns)
at System.Windows.Forms.DataGridViewColumnCollection.AddRange(DataGridViewColumn[] dataGridViewColumns)

找了好半天才找出问题的原因,绑定的属性在数据库表中不存在的列名

解决方案如下 :

1. 绑定的字段一定要与数据库表中的列的字段名相同

2. 如果是模型,这个模型的属性字段在数据库中没有,那就不用把属性写在datagridView 的列中,在设置datasource 后,直接设置列的可见 性

WinForm Column cannot be added because its CellType property is null.的更多相关文章

  1. 【Oracle 12c】最新CUUG OCP-071考试题库(53题)

    53.(12-14) choose the best answer: Examine the command to create the BOOKS table. SQL>CREATE TABL ...

  2. xUtils3的简单介绍

    xUtils3的简介 xUtils是基于Afinal开发的目前功能比较完善的一个Android开源框架,最近又发布了xUtil3.0,在增加新功能的同时又提高了框架的性能. 1.xUtils包含了很多 ...

  3. xUtils使用详细介绍

    xUtils3使用详解 一.xUtils简介: xUtils是基于Afinal开发的目前功能比较完善的一个Android开源框架,官网:https://github.com/wyouflf/xUtil ...

  4. Android Xutils3 完全解析

    1.先来认识一下xUtils3 1)xUtils3简介 xUtils是基于Afinal开发的目前功能比较完善的一个Android开源框架,最近又发布了xUtil3.0,在增加新功能的同时又提高了框架的 ...

  5. Mysql官方文档中争对安全添加列的处理方法。Mysql Add a Column to a table if not exists

    Add a Column to a table if not exists MySQL allows you to create a table if it does not exist, but d ...

  6. 详解如何利用FarPoint Spread表格控件来构造Winform的Excel表格界面输入

    我们先来简单了解一下WinForm和FarPoint,WinForm是·Net开发平台中对Windows Form的一种称谓.而FarPoint是一款模拟EXCEL的控件.它可以根据用户的要求实现很大 ...

  7. oracle ORA-01747(系统保留关键字)user.table.column, table.column 或列说明无效 hibernate映射oracle保留关键字

    1.查询系统关键 select * from v$reserved_words 确认你使用的是否为关键字: select * from v$reserved_words w where w.KEYWO ...

  8. 11G新特性 -- Multicolumn Statistics (Column groups)

    默认oracle会收集表中各个列的统计信息,但是会忽略列之间的关联关系.在大多情况下,优化器假设在复杂查询中的列之间是独立的.当where子句后指定了一个表的多个列条件时,优化器通常会将多个列的选择性 ...

  9. mybatis column 和property

    mybatis map文件中 resultMap中column和sql查询结果对应, property和实体private对应 <resultMap id="VideoYcAppRes ...

随机推荐

  1. linux tar 压缩

    压缩文件 tar -czvf xxx.tar.gz yourdict 解压文件 tar xzf aa.tar.gz

  2. How to map host ip and port to Hyper-V

    1.1       Add an port proxy netsh interface portproxy add v4tov4 listenport=hostport listenaddres=ho ...

  3. java 蓝桥杯算法提高 矩阵乘法

    思路:根据提示的内容,我们可以得到c[i][j] += a[i][k]*b[k][j],k>=0&&k<s PS:这道题本身不难,但是当我定义A[m][s] B[s][n] ...

  4. ElasticSearch的java api

    pom <dependencies> <dependency> <groupId>org.elasticsearch.client</groupId> ...

  5. CentOS安装配置Tomcat-7

    安装环境:CentOS-6.5安装方式:源码安装软件:apache-tomcat-7.0.29.tar.gz下载地址:http://tomcat.apache.org/download-70.cgi ...

  6. C#中接口声明属性,但是提示“接口”中不能有属性。

    C#中接口定义属性如下所示: using System; using System.Collections.Generic; using System.Linq; using System.Text; ...

  7. 最小生成树 prim

    1.算法思想: 图采用邻接矩阵存储,贪心找到目前情况下能连上的权值最小的边的另一端点,加入之,直到所有的顶点加入完毕. 2.算法实现步骤: 设图G =(V,E),其生成树的顶点集合为U. (1)把v0 ...

  8. Python 日期和时间戳的转换

    Python 日期和时间戳的转换 1. Python中处理时间的模块 Python中处理时间的模块有time.datetime和calendar. 在Python中表示时间的方式: 时间戳:10位整数 ...

  9. Spring.net 后处理器 可用来切换实例

    .xml配置 <!--我们在Object.xml文件上将HexuObjectPostProcessor注册到上下文对象中去--> <object id="hexu" ...

  10. 1 Python入门及计算机硬件知识

    一: Python是一种编程语言 语言: 语言是一种事物与另外一种事物沟通的介质 所以说编程语言是程序员和计算机之间实现沟通的桥梁 什么是编程?: 编程就是程序员用计算机所能理解的表达方式(编程语言) ...