如何选中复选框被选中或不是数据网格 [英] how to check checkbox is selected or not datagrid

查看:81
本文介绍了如何选中复选框被选中或不是数据网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

for (int intCount = 0; intCount < gvCustomer.Rows.Count; intCount++)
                    {
                        bool chkischeck=false;
                        string strcheck = "";
                   

                     
  ch1 = (DataGridViewCheckBoxCell)gvCustomer.Rows[intCount].Cells[1];
                       if (ch1.Selected)
                       
                        {
  intGridID =Convert.ToInt32(gvCustomer.Rows[intCount].Cells[0].Value);
                            m_Id = intGridID;
                            DeleteData();

                        }


                    }







在此代码中如果第一行[0]和第二行[1]被选中则它不显示ch1.Selected = true

第一行显示它显示真实[1]计数而不是for count [0]




in this code if first row [0] and second row [1] selected then it doesnot show ch1.Selected=true
for first row it show it show true [1] count and not for count [0]

推荐答案

Quote:

如何选中复选框被选中或不是datagrid

how to check checkbox is selected or not datagrid



这样的事情:


Some thing like this:

foreach (GridViewRow row in GridView1.Rows)
    {
        // Use find control to get the check boxes in grid.
        CheckBox checkbox = (CheckBox)row.FindControl("cbRows");
        //Check if the checkbox is checked.
        if (checkbox.Checked)
        {
            // you will come to know here the check box is selected or not.
        }
    }


这篇关于如何选中复选框被选中或不是数据网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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