0
votes

I have a DevExpress' ASPxGridView with some data.

This grid provides a functionality that allows me to change the order its the columns. For example, I got this columns:

enter image description here

And I can do this with them:

(Note that I've changed the order of PC-PEC and DES-CAP columns)

As you can see, the data and column names have changed, but the color of the cells still the same. And I can't figure out how to do that. I haven't found any event the grid fires when I switch the columns that can help me.

Here is how I set the colors of the cells:

Protected Sub grdxOperacao_HtmlRowPrepared(ByVal sender As Object, ByVal e As DevExpress.Web.ASPxGridView.ASPxGridViewTableRowEventArgs)
    'I delete some code here for the sake of brevity
    e.Row.Cells(4).Attributes.Add("style", "font-weight:bold;color:red;")
End Sub

Maybe if I could find a way to paint them by anything than the index it would work? Or maybe something via javascript, I don't know.

Thank you very much.

1

1 Answers

1
votes

You should use ASPxGridView.HtmlDataCellPrepared Event.

protected void ASPxGridView1_HtmlDataCellPrepared(object sender, ASPxGridViewTableDataCellEventArgs e) {
    if (e.DataColumn.FieldName == "<your column field name>") 
    {
        e.Cell.ForeColor = System.Drawing.Color.Red;
    }
}