2

I have a GridView that has a column with RepositoryItemCheckEdit as ColumnEdit. I want to disable this control for just one row. How can I do this? Any suggestions?

Hans Espen
  • 1,127
  • 6
  • 14
  • 22

3 Answers3

3

I have found a solution to the problem.

gridView1.CustomRowCellEditForEditing += OnCustomRowCellEditForEditing;

private void OnCustomRowCellEditForEditing(object sender, CustomRowCellEditEventArgs e)
{
    if (e.Column.FieldName != "MyFieldName") return;
        *code here*
        e.RepositoryItem.ReadOnly = true;
}
Hans Espen
  • 1,127
  • 6
  • 14
  • 22
2

you can make the editor read only by handling CustomRowCellEdit:

private void gridView1_CustomRowCellEdit(object sender, CustomRowCellEditEventArgs e)
{
    if(code goes here)
        e.RepositoryItem.ReadOnly = true;
}

you can also prevent the editor from being show by handling ShowingEditor:

private void gridView1_ShowingEditor(object sender, CancelEventArgs e)
{
    if (code goes here)
        e.Cancel = true;
}
0

in the class that inherits DataGridViewColum override method InitializeEditingControl it has parameter rowIndex the write something like this

this.DataGridView.EditingControl.Enbale = rowIndex != 3; // or the number you need
IordanTanev
  • 6,130
  • 5
  • 40
  • 49