在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. ubuntu kylin 设置 wifi

    左上侧  搜索资源 输入 软件和更新  点击软件和更新,点击附加驱动,点击使用无线驱动.

  2. shell if,case,for,while语法

    #shell if的语法 if [空格 xxx 空格] then echo xxxxx exit 1/2/3/4/.... 0表示正确. elif [空格 xxx 空格] then echo xxxx ...

  3. windows下怎么安装protobuf for python

    首先从google上下载protobuf-3.0.0.zip和protoc-3.0.0-win32.zip,然后把protoc-3.0.0-win32.zip里的protoc.exe放到protobu ...

  4. Openssl CA.pl命令

    一.简介 CA.pl是证书操作的友好接口,简化了一些相似的证书创建或管理操作 二.语法 CA.pl [-?] [-h] [-help] [-newcert] [-newreq][-newreq-nod ...

  5. code4511 信息传递

    寻找最小环 #include <cstdio> #include <cstring> #include <iostream> using namespace std ...

  6. Win10系统SQL数据库安装

    Win10系统MySQL数据库安装 1. 安装文件下载 下载地址: https://downloads.mysql.com/archives/community/ 下载版本: mysql-8.0.15 ...

  7. hadoop分布式集群搭建前期准备(centos7)

    那玩大数据,想做个大数据的从业者,必须了解在生产环境下搭建集群哇?由于hadoop是apache上的开源项目,所以版本有些混乱,听说都在用Cloudera的cdh5来弄?后续研究这个吧,就算这样搭建不 ...

  8. zigbee之IAR环境搭建

    注册机第一个要选择: 为什么? 之前说CC2530是支持zigbee协议的无线芯片,其实它是这款硬件上有一个支持zigbee协议的无线电路,不仅有这款电路,而且还有一块cpu电路,它就是8051cpu ...

  9. IBatis模糊查询

    IBatis模糊查询  补充: mysql中模糊查询的四种用法: 1,%:表示任意0个或多个字符.可匹配任意类型和长度的字符,有些情况下若是中文,请使用两个百分号(%%)表示. 比如 SELECT * ...

  10. 扩展JPA方法,重写save方法

    为什么要重构save? jpa提供的save方法会将原有数据置为null,而大多数情况下我们只希望跟新自己传入的参数,所以便有了重写或者新增一个save方法. 本着解决这个问题,网上搜了很多解决方案, ...