如何检查datagridview中是否选中了复选框 [英] How to check if checkbox is checked in datagridview

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

问题描述

这是我的代码,我想查看我的datagridview中的复选框...请帮助我...



This is my code and i want to check the checkbox in my datagridview... Please help me...

if (sdr[6].ToString().Equals("1"))
                {
                    //dataGridView1.Rows[i].Cells["Column8"].Selected = true;
                }
                else
                {
                    //dataGridView1.Rows[i].Cells["Column8"].Selected = false;
                }







i是行的反击。和sdr [6]是来自数据库的数据。我该怎么办if。




i is the counter of row. and sdr[6] is the data from database. what should I do in if.

推荐答案

请看我过去的答案:

如何统计c#中datagridview的复选框? [ ^ ] 。



-SA
Please see my past answer:
how to count checked checkboxes of datagridview in c#?[^].

—SA


如果要检查选中的复选框,请尝试使用此代码或不是:

Try this code if you want to check wheather checkBox is selected or not:
for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
    {
            GridViewRow row = GridView1.Rows[i];
            CheckBox Ckbox = (CheckBox)row.FindControl("CheckBox2");
            if (Ckbox.Checked)
            {
               //your code for selected checkbox
            }
    }


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

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