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?
Asked
Active
Viewed 1.4k times
3 Answers
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;
}

Kevin Clark
- 61
- 3
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
-
Thanks for your reply. However, isn't your solution for Windows.Forms DataGridView? I am using Devexpress XtraGrid – Hans Espen Jan 07 '10 at 13:46
-
My mistake yes this is for Windows.Forms DataGridView – IordanTanev Jan 07 '10 at 15:43