I am new to posting on Stack. I have searched for quite some time to a problem similar to mine. I am trying to change the checkboxes in a WinForms DataGridView from not read-only to read-only based on the object's boolean value dynamically.
It is showing in debug mode that the change has happened but once it fully runs through, the checkbox cells that are supposed to be read only are still allowing check and uncheck functionality. I have left the commented out section in to show that I have attempted to do this.
m_SingletonForm.dataGridView1.DataSource = list;
m_SingletonForm.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
m_SingletonForm.dataGridView1.Columns["StoreGroup"].ReadOnly = true;
m_SingletonForm.dataGridView1.Columns["Message"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
m_SingletonForm.dataGridView1[0, 0].ReadOnly = true;
foreach (DataGridViewRow row in m_SingletonForm.dataGridView1.Rows)
{
//var isChecked = Convert.ToBoolean(row.Cells["SendFile"].Value);
//if (!isChecked)
//{
//m_SingletonForm.dataGridView1.Rows[0].Cells["SendFile"].Style.BackColor = Color.Red;
//m_SingletonForm.dataGridView1.Rows[0].Cells["SendFile"].ReadOnly = true;
//m_SingletonForm.dataGridView1.Rows[row.Index].Cells["SendFile"].Style.BackColor = Color.Red;
//m_SingletonForm.dataGridView1.Rows[row.Index].Cells["SendFile"].ReadOnly = true;
//m_SingletonForm.dataGridView1["SendFile", row.Index].ReadOnly = true;
//m_SingletonForm.dataGridView1["SendFile", row.Index].Style.BackColor = Color.Red;
// }
}
m_SingletonForm.label1.Text = message;
m_SingletonForm.Text = title;
MessageBox.Show(m_SingletonForm.dataGridView1[0, 0].ReadOnly.ToString());
m_SingletonForm.ShowDialog();
Any help would be greatly appreciated.