Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change font color in gridview DevExpress c#

How can I change the font color on gridview of DevExpress? All the solutions I have found are about changing the forecolor and the backcolor..

I want to have a red font in case a value in a cell is negative.

Any suggestion?

like image 656
Stavros Avatar asked Oct 25 '11 13:10

Stavros


2 Answers

Sign for RowCellStyle event and set ForeColor there

    private void gridView1_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
    {
        if(e.Column.FieldName == "Field2")
        {
            var data = gridView1.GetRow(e.RowHandle) as Sample;
            if(data == null)
                return;

            if (data.Field2 < 0)
                e.Appearance.ForeColor = Color.Red;
        }
    }

enter image description here

like image 188
Stecya Avatar answered Oct 16 '22 09:10

Stecya


You want to take a look at the conditional formatting rules.

DevExpress Conditional Formatting

like image 34
fluent Avatar answered Oct 16 '22 09:10

fluent