想要在datagridview中选中的复选框 [英] Checkbox want to be checked in datagridview
本文介绍了想要在datagridview中选中的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我在datagridview中添加了3个复选框列.如果我单击该复选框,则不对其进行检查吗?
如果我单击要检查的复选框,但无法获取要检查的复选框
如何解决问题
Hi
I added 3 check box columns in the datagridview .if i clicked the checkbox it not to be checked?
if i click the checkbox it want to be checked.but not able to get checkbox to be checked
how to solve the problem
推荐答案
<ItemTemplate><asp:CheckBox ID="CheckBox1" runat="server"
oncheckedchanged="CheckBox1_CheckedChanged" /></ItemTemplate>
在datagridview的桌面添加事件中
in desktop add event for datagridview
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 1)
{
if (DataGridView1.Rows[e.RowIndex].Cells[1].Value == null || DataGridView1.Rows[e.RowIndex].Cells[1].Value == DBNull.Value || Convert.ToBoolean(DataGridView1.Rows[e.RowIndex].Cells[1].Value) == false)
{
DataGridView1.Rows[e.RowIndex].Cells[1].Value = true;
}
}
}
这篇关于想要在datagridview中选中的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文