C # readonly DataGridView with one cell enabled

I have a readtly datagridview, in some particular case I need to include one cell after the double-click row (make readonly = false and focus on that particular cell in the current row (for example, enter it - the cursor should start blinking).

I have:

private void dataGridView1_DoubleClick(object sender, EventArgs e) { dataGridView1.Cells[3].ReadOnly = false; } 

But that will not work. Why?

+2
source share
2 answers

Try setting the current Datagridview cell and calling BeginEdit

  private void dataGridView1_DoubleClick(object sender, EventArgs e) { dataGridView1.Cells[3].ReadOnly = false; this.dataGridView1.CurrentCell = dataGridView1.Cells[3]; dataGridView1.BeginEdit(true); } 

http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.beginedit.aspx

+1
source

dataGridView1 The ReadOnly property must be set to false. For each ReadOnly property of the row, true must be set. then, if necessary, you can set the ReadOnly cell to true.

 //setting each row foreach (DataGridViewRow row in dataGridView1.Rows) { row.ReadOnly = true; } //setting on cell DataGridViewCell cell = dataGridView1.Rows[e.RowIndex].Cells[3]; dataGridView1.CurrentCell = cell; dataGridView1.CurrentCell.ReadOnly = false; dataGridView1.BeginEdit(true); 
+2
source

All Articles