添加基于DataGridViewCheckBoxCell的Image列

时间:2013-01-16 12:09:31

标签: c# image for-loop datagridview

这就是我编码的内容:

private void DeleteButton_Click(object sender, EventArgs e)
    {
        //Add column for status
        DataGridViewImageColumn imageColumn = new DataGridViewImageColumn();
        imageColumn.Name = "ImageColumn";
        imageColumn.HeaderText = "Status";
        FilesDataGridView.Columns.Add(imageColumn);
        FilesDataGridView.Columns[2].Width = 45;

        foreach (DataGridViewRow dr in FilesDataGridView.Rows)
        {
            DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dr.Cells["ChkColumn"];

            DataGridViewImageCell cell = dr.Cells[2] as DataGridViewImageCell;


            if (checkCell.Selected == true)
            {
                //need code to display the Image for this column here..
            }
            else
            {
                //need code to display the Image for this column here..
            }
        }
    }

0 个答案:

没有答案