views:

1213

answers:

3

Hi

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?

A: 

Hi, 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
Thanks for your reply. However, isn't your solution for Windows.Forms DataGridView? I am using Devexpress XtraGrid
Hans Espen
My mistake yes this is for Windows.Forms DataGridView
IordanTanev
A: 

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  A: 

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