本文介绍了如何检查Datagridviewcheckboxcolumn是否已经过cheked的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在运行时生成datagridviewcheckboxcolumn但我不知道怎样才能检查
它的被检查属性是真还是假....
plz任何人帮我...(在Windows应用程序中)
提前感谢.....
i m generating datagridviewcheckboxcolumn in run time but i don't know how can i check
it's checked property true or false....
plz any one help me...(In Windows Application)
thanks in advance.....
推荐答案
foreach (DataGridViewRow dataGridRow in dataGridView1.Rows)
{
if (dataGridRow.Cells["YourCheckboxColumn"].Value != null && (bool)dataGridRow.Cells["YourCheckboxColumn"].Value)
{
// Checked
}
else if (dataGridRow.Cells["YourCheckboxColumn"].Value == null)
{
// Unchecked
}
}
:)
Regard
Sham
:)
Regard
Sham
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
CheckBox chk = (CheckBox)(e.Row.FindControl("CheckBoxId"));
If(chk.Text == "MyName")
{
chk.Checked = true;
}
}
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox chk = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("CheckBox1");
if (chk.Checked)
{
//your logic
}
}
在Cells [index]中,你的索引是你的复选框列位置的位置。
希望你找到你的解决方案。
有趣的编码....
Here in Cells[index], your index is the position of your checkbox column location.
Hope you find your solution.
Fun coding....
这篇关于如何检查Datagridviewcheckboxcolumn是否已经过cheked的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!