WinForm Column cannot be added because its CellType property is null.
在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.的更多相关文章
- 【Oracle 12c】最新CUUG OCP-071考试题库(53题)
53.(12-14) choose the best answer: Examine the command to create the BOOKS table. SQL>CREATE TABL ...
- xUtils3的简单介绍
xUtils3的简介 xUtils是基于Afinal开发的目前功能比较完善的一个Android开源框架,最近又发布了xUtil3.0,在增加新功能的同时又提高了框架的性能. 1.xUtils包含了很多 ...
- xUtils使用详细介绍
xUtils3使用详解 一.xUtils简介: xUtils是基于Afinal开发的目前功能比较完善的一个Android开源框架,官网:https://github.com/wyouflf/xUtil ...
- Android Xutils3 完全解析
1.先来认识一下xUtils3 1)xUtils3简介 xUtils是基于Afinal开发的目前功能比较完善的一个Android开源框架,最近又发布了xUtil3.0,在增加新功能的同时又提高了框架的 ...
- 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 ...
- 详解如何利用FarPoint Spread表格控件来构造Winform的Excel表格界面输入
我们先来简单了解一下WinForm和FarPoint,WinForm是·Net开发平台中对Windows Form的一种称谓.而FarPoint是一款模拟EXCEL的控件.它可以根据用户的要求实现很大 ...
- 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 ...
- 11G新特性 -- Multicolumn Statistics (Column groups)
默认oracle会收集表中各个列的统计信息,但是会忽略列之间的关联关系.在大多情况下,优化器假设在复杂查询中的列之间是独立的.当where子句后指定了一个表的多个列条件时,优化器通常会将多个列的选择性 ...
- mybatis column 和property
mybatis map文件中 resultMap中column和sql查询结果对应, property和实体private对应 <resultMap id="VideoYcAppRes ...
随机推荐
- (转)C#命名规范
C#命名规范 数据类型 数据类型简写 标准命名举例 Array arr arrShoppingList Boolean bln blnIsPostB ...
- zt <Windows Image Acquisition (WIA)> from msdn
Windows Image Acquisition (WIA) Windows Image Acquisition (WIA) is the still image acquisition pla ...
- springboot 跳过单元测试
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-suref ...
- jsp table td自动换行
<TABLE style="word-wrap: break-word; word-break: break-all;">
- js引用类型赋值,深拷贝与浅拷贝
JS中引用类型使用等号“=” 赋值,相当于把原来对象的地址拷贝一份给新的对象,这样原来旧的对象与新的对象就指向同一个地址,改变其中一个对象就会影响另外那个对象,也就是所谓的浅拷贝.例如: var ar ...
- Vertex and fragment programs
[Vertex and fragment programs] When you use vertex and fragment programs (the so called "progra ...
- Excel VBA入门(四)流程控制2-循环控制
所谓循环控制,即在循环执行一段代码,用于完成一些重复性任务. VBA中的循环控制语句主要有3种:for.while.loop.对于大多数人来说,for的使用频率最高,而我个人也觉得for是最为灵活的, ...
- Linux显示文件前几行、拷贝文件前几行、删除文件前几列
[一]显示文件前几行 ll -lrth:按照更改时间倒序排列,最新文件在下边 ll -lrSh:按照文件大小倒序排列,最大文件在下边 grep --color :高亮查询关键字 grep -A 10 ...
- IDEA错误的忽略了智能补全代码,导致正确的代码自动提示不出来的问题
标题说起来有点绕,当今大部分IDE都提供 Alt+Enter 呼出自动补全菜单的功能,IDEA也不例外,今天手残了一下,具体问题如下: 1. 通常我们键入一个自定义类时IDEA会自动提示为红色,表示缺 ...
- ubuntu tensorflow cpu Faster-RCNN配置参考
https://blog.csdn.net/qq_36652619/article/details/85006559 (参考) https://blog.csdn.net/zcy0xy/art ...