开发者

loop through datagridview column and check checkbox

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

End and Swe are nor开发者_开发百科mal strings and update and hide are checkboxes.

I want to make two buttons now:

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

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

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.

I appreciate all the help.


    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;
        }
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜