スタックに投稿するのは初めてです。私は自分に似た問題をかなりの時間探しました。オブジェクトのブール値に基づいて、WinForms DataGridView のチェックボックスを読み取り専用から読み取り専用に動的に変更しようとしています。
変更が発生したことがデバッグ モードで示されていますが、完全に実行されると、読み取り専用であるはずのチェックボックス セルで引き続きチェックおよびチェック解除機能が許可されます。これを試みたことを示すために、コメントアウトされたセクションを残しました。
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();
どんな助けでも大歓迎です。