如何在DataGridView中的特定celle中创建DataGridViewCheckBoxCell [英] How to create a DataGridViewCheckBoxCell in a specific celle in DataGridView

查看:72
本文介绍了如何在DataGridView中的特定celle中创建DataGridViewCheckBoxCell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Good morning,

I contact you because I have a problem in my C# program.

I am using a basic DataGridView with four DataGridViewTextBoxColumn. And I would like to add a checkbox with a label in a specific cell of the data grid view (for example in the cell at the position Row[0]-Column[0]).

I try this :




DataGridViewCell ch1 = new DataGridViewCheckBoxCell();
this.dataGridView1.Rows[0].Cells[0] = ch1;




But it is not working and I have an exception concerning the type of the cell when I run the application.

I would like to know if the thing that I want to do is possible and if someone have an idea to do that.

Thank you in advance.

推荐答案

尝试DataGridTemplateColumn.CellTemplate。

http://msdn.microsoft.com /en-us/library/system.windows.controls.datagridtemplatecolumn.celltemplate(v=vs.110).aspx [ ^ ]
Try DataGridTemplateColumn.CellTemplate.
http://msdn.microsoft.com/en-us/library/system.windows.controls.datagridtemplatecolumn.celltemplate(v=vs.110).aspx[^]


这篇关于如何在DataGridView中的特定celle中创建DataGridViewCheckBoxCell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆