如何检索datagridview复选框值 [英] How to retrieve datagridview checkbox values

查看:54
本文介绍了如何检索datagridview复选框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





在我的项目中我使用datagridviewcheckbox,我可以将这个datagridviewcheckbox值保存在数据库中,这里我想检索同一datagridviewcheckbox中的复选框值。我怎样才能做到这一点。对于Windows应用程序。



谢谢你

Hi,

In my project am I using datagridviewcheckbox , I can save this datagridviewcheckbox value in database, Here I want to retrieve the checkbox value in the same datagridviewcheckbox . How Can I do this. For windows application.

Thank You

推荐答案

你好Mekalamani,见下面的例子,

Hi Mekalamani, see the below example,
DataTable objTable = new DataTable();
objTable.Columns.Add("Selection", typeof(bool));
objTable.AcceptChanges();

DataRow NewRow1 = objTable.NewRow();
NewRow1["Selection"] = false;
objTable.Rows.Add(NewRow1);

DataRow NewRow2 = objTable.NewRow();
NewRow2["Selection"] = true;
objTable.Rows.Add(NewRow2);

objTable.AcceptChanges();

dataGridView1.DataSource = objTable;



这里,将 objTable 分配给 dataGridView1.DataSource ,DataGridView自动将布尔值显示为复选框列。像这样,您可以将数据类型设置为bool,以显示为DataGridViewCheckBoxColumn。


Here, when assigning objTable to dataGridView1.DataSource, the DataGridView automatically display the boolean values as checkbox column. Like this, you can make your datatype to bool for your data, which is to be displayed as DataGridViewCheckBoxColumn.


这篇关于如何检索datagridview复选框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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