在WINFORM中编写,用DataGridView绑定数据后自动将数据库中的列显示出来了,要对处于中间的一列的显示格式进行修改,自动绑定产生的列都是TextBox格式,要想显示成ComboBox应该怎么办?速.
解决方案 »
- 求高人指教,求一段C#代码,实现从txt文件中选取所有时间记录。
- c#如何生成自定义格式(标签)的xml
- 关于treeview中treenode节点编辑时的鼠标焦点问题
- 下面是数据库的的.net data driver , 可以在那里下载到?
- 如何让控件都靠左,或者都靠右
- 哪位好心的大侠能提供给小弟C#入门源码?
- zglxh3(noproblem),接分之六
- 运行时遇到了错误。此错误的地址为 0x791f7e06,在线程 0xe24 上。错误代码为 0xc0000005
- AForge.Video 摄像头快门事件.求解救.
- 请教在写入XML文件时,怎么在WriteStartDocument时写入encoding?
- 怎样删除事件委托链表中的某个委托
- 为什么前面一定要先赋值?
幸亏 L主 又解释了一边 不然没有看得懂的
==========
其实 很简单
(第4列)显示为下拉列表 微软在这个方面做得很好,,他可以独立去绑定数据源
开始的时候,,你把其他的列绑定完之后,,接着写this.第4列的列名.DataSourde= ds.Tables[0]; //s数据源
this.第4列的列名.DisplayMember = " ";
this.第4列的列名.ValueMember = " ";那个列名 直接 可以点出来...............
谁能帮我把这段解释一下:
((DataGridViewComboBoxCell)dgPersonnel["性别", i]).DataSource = ds.Tables[0].DefaultView;
((DataGridViewComboBoxCell)dgPersonnel["性别", i]).ValueMember = "性别";
((DataGridViewComboBoxCell)dgPersonnel["性别", i]).DisplayMember = "性别";
((DataGridViewComboBoxCell)dgPersonnel["性别", i]).DataSource = ds.Tables[0].DefaultView;
这句产生了个错误:
无法将类型为“System.Windows.Forms.DataGridViewCheckBoxCell”的对象强制转换为类型“System.Windows.Forms.DataGridViewComboBoxCell”。
应该怎样修改?
=========
((DataGridViewComboBoxCell)dgPersonnel["性别", i]).DataSource = ds.Tables[0].DefaultView;
((DataGridViewComboBoxCell)dgPersonnel["性别", i]).ValueMember = "性别";
((DataGridViewComboBoxCell)dgPersonnel["性别", i]).DisplayMember = "性别";为什么还要 加 i,, 绑定 的意思是他内部 会自动循环
而起 你 到处 转换 ,,,是什么意思.........................................?
晕 !不可能 不行的.....?
=========
((DataGridViewComboBoxCell)dgPersonnel["性别", i]).DataSource = ds.Tables[0].DefaultView;
((DataGridViewComboBoxCell)dgPersonnel["性别", i]).ValueMember = "性别";
((DataGridViewComboBoxCell)dgPersonnel["性别", i]).DisplayMember = "性别";为什么还要 加 i,, 绑定 的意思是他内部 会自动循环
而起 你 到处 转换 ,,,是什么意思.........................................?总算学了点东西,谢了.
是不是我的数据设置有问题,为什么不能转换呢?