Search code examples
c#gridcontroldevexpress-windows-ui

find checkedit control in devexpress gridcontrolrow in c#


I have devexpress grid control in my windows form. And i have check edit control inside my grid . I need to find checkedit control at runtime from each row and based on other cell value i need to disable the checkbox if required.

Plz suggest!.

Regards & Thanks


Solution

  • Handle the ShowingEditor event to prevent the cell from being edited.

    private void gridView1_ShowingEditor(object sender, CancelEventArgs e)
    {
         DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView;
    
        if (view.FocusedColumn.FieldName == "<name of check field>" && view.GetRowCellValue(view.FocusedRowHandle, "<other field>").ToString()!="editable value"))
               e.Cancel = true;
    }