简体   繁体   中英

c# DataGridView: Edit Row Cell at Runtime

In designer I have placed a DataGridView and added several columns. I set the "ReadOnly" property of the DataGridView to false and all of the columns' "ReadOnly" to true, except for one titled "Details".

At runtime, I have an event handler add a row using dataGridViewInstance.Rows.Add(row); where row is a string array.

After it is added I would like to be able to select the cell under the "Details" column and make notes but it will not accept my input.

Any idea how I can do this?

Thanks!

you can do like this....

try comparing with any checkbox state in form like this...

 private void CheckBox1_CheckedChanged(System.Object sender, System.EventArgs e)
 {

   DataGridViewColumn dgvColumn = this.DataGridView1.Columns("Details");

    if (this.CheckBox1.CheckState == CheckState.Checked)
    {
         dgvColumn.ReadOnly = true;
    }
    else 
    dgvColumn.ReadOnly = false;              

 }

i hope it will helps you...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM