如何使用C#在datagridview中获取选中的复选框 [英] How to get selected check boxes in datagridview using C#

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

问题描述

你好,
我想如何在datagridview中获取选中的复选框,我已经插入了记录,现在要更新,我需要选中选中的复选框进行更新,您可以指导或发送任何代码片段

Hello,
i want how to get selected checboxes in datagridview , i have already inserted record now i am going to updating i need to get selected check boxs for updating which was previosly selected can u guide or send any snippets

推荐答案

尝试以下操作:
Try this:
protected void btnDelete_Click(object sender, EventArgs e)
    {
 
        foreach (GridViewRow grow in GridView1.Rows)
        {
            CheckBox chkStat = grow.FindControl("chkStatus") as CheckBox;
            int index = grow.RowIndex;
            if (chkStat.Checked)
            {
                //Write some code if checkbox is checked
            }
            else
            {
                //Write some code if checkbox is not checked
            }
        }
    }


我肯定在DataGridView内部切换所有Checkbox的状态列 [
I''m certain this discussion[^] should help you out.

In general, Toggling the States of all CheckBoxes Inside a DataGridView Column[^] is a good read to understand the working of checkboxes in a DataGridview.


这篇关于如何使用C#在datagridview中获取选中的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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