循环遍历 datagridview 列并选中复选框 [英] loop through datagridview column and check checkbox

查看:42
本文介绍了循环遍历 datagridview 列并选中复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含四列的 DataGridView:Eng、Swe、更新和隐藏.

I have a DataGridView with four columns: Eng, Swe, update and hide.

End 和 Swe 是普通字符串,而 update 和 hide 是复选框.

End and Swe are normal strings and update and hide are checkboxes.

我现在想做两个按钮:

Button1:全部更新"此按钮将遍历列更新更新中的所有复选框,并将值设置为 true(选中).

Button1: "Update all" this button shall loop through all the checkboxes in the column update update and set the value to true (checked).

Button2:隐藏"此按钮将遍历列隐藏中的所有复选框并将值设置为 true(选中).

Button2: "Hide" this button shall loop through all the checkboxes in the column hide and set the value to true (checked).

任何人都可以帮助我如何做到这一点,如何让程序理解当我按下 Button1 时,更新"列中的所有复选框都应被选中.

Can anyone please help me how to do this, how to make the program understand that when I press Button1 that all the checkboxes in the column "Update" shall be checked.

感谢所有帮助.

推荐答案

    private void UpdateAllButton_Click(object sender, EventArgs e)
    {
        foreach (DataGridViewRow row in dataGridView1.Rows)
        {
            row.Cells["update"].Value = true;
        }
    }

    private void HideButton_Click(object sender, EventArgs e)
    {
        foreach (DataGridViewRow row in dataGridView1.Rows)
        {
            row.Cells["hide"].Value = true;
        }
    }

这篇关于循环遍历 datagridview 列并选中复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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