1
votes

I have a GridControl view which is being populated with one column as a Boolean to show the value as a checkbox.

However, I wish to hide some checkboxes based on the state of other columns. I have tried to use the gridView_CustomDrawCell() event but cannot find a suitable property.

I expected to find a visible property to set to false but there doesn't seem to be one.

Maybe it is possible to hide the checkbox when the view is being populated but I cannot think of one.

Does anyone know if this is possible, and how?

Many thanks!

2

2 Answers

4
votes

You could try to clear the Graphics and mark the event as handled :

private void gridView_CustomDrawCell(object sender, RowCellCustomDrawEventArgs e)
{
    if (ConditionIsMet())
    {
        e.Graphics.Clear(e.Appearance.BackColor);
        e.Handled = true;
    }
}

If it doesn't work, here's another idea : handle the CustomRowCellEdit and CustomRowCellEditForEditing events, and remove the editor :

private void gridView_CustomRowCellEdit(object sender, CustomRowCellEditEventArgs e)
{
    if (ConditionIsMet())
    {
        e.RepositoryItem = null;
    }
}
4
votes

What I did for this on a project was to set a RadioGroup as the control with no items so it appeared as blank.

private void viewTodoList_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
        {
            if (e.Column == CheckMarkColumn)
            {
                if (ConditionIsMet())
                {
                    e.RepositoryItem = new DevExpress.XtraEditors.Repository.RepositoryItemRadioGroup();
                }
            }
        }