DataGridView CheckBoxCell-选中的属性 [英] DataGridView CheckBoxCell - Checked Property
本文介绍了DataGridView CheckBoxCell-选中的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用C#开发窗口应用程序.我的应用程序中有一个DataGridView,还有一个CheckBox列.我的应用程序中也有一个按钮.单击按钮后,我想显示DataGridView的选中单元格计数.我怎样才能做到这一点?以及如何确保DataGridView的选中属性?
I am developing a window application using C#. I have a DataGridView in my application and a CheckBox column. I also have a button in my application. When the button is clicked I want to show a count of checked cells of DataGridView. How can I do this? And how can I ensure the checked property of DataGridView?
推荐答案
您可以尝试以下操作:
You can try this:
int checked = 0;
foreach (GridViewRow row in metroGridView.Rows)
{
CheckBox cb = (CheckBox)row.FindControl("myCheckBox");
if (cb != null)
{
if (cb.Checked)
{
checked++;
}
}
}
这篇关于DataGridView CheckBoxCell-选中的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文