I am new to publishing on Stack. I searched for quite a while a problem similar to mine. I am trying to change the checkboxes in WinForms DataGridView from not only read, but read only based on the dynamic value of the object.
It shows in debug mode that this happened, but as soon as it passes completely, the flag cells, which should only be read, still allow you to check and cancel the functionality. I left a commented section to show that I tried 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.
source share