2

As the subject indicates, I have a DevComponents DotNetBar SuperGridControl (SGC) on my Windows Form. In that SGC, I have alternating row colors. One of the columns in the SGC has boolean values (enabled/disabled flag in the data).

I would like to change the background color of JUST the rows that are marked with a false boolean value.

The code I've attempted to use to perform this task:

    private void dgvSearchResults_PostRenderRow(object sender, GridPostRenderRowEventArgs e)
    {
        if (e.RenderParts != RenderParts.Background) { return; }

        var row = (GridRow)e.GridRow;

        if (((CustomerDTO)row.DataItem).Disabled)
        {
            //Try to figure out how to set the row color here.
        }
    }

The nasty part of this is that this code apparently runs twice for every row in the SGC. But, that part aside, there doesn't seem to be any way to change the row color of the row that I'm in when I get into the .Disabled control statement.

I'd love any tips or suggestions.

PKD
  • 685
  • 1
  • 13
  • 37

1 Answers1

1

So I actually did sort out an answer to this one, and it turns out it was fairly simple. I was just calling the wrong event handler. The below code performs the exact task I was attempting in my initial question:

    private void dgvSearchResults_GetRowCellStyle(object sender, GridGetRowCellStyleEventArgs e)
    {
        if (e.StyleType != StyleType.Default) { return; }

        var row = e.GridRow as GridRow;
        if (row == null) { return; }

        if (((CustomerDTO)row.DataItem).Disabled) {
            e.Style.Background = new Background(Color.Tomato);
        }
    }
PKD
  • 685
  • 1
  • 13
  • 37