Home Forums WinForms controls Xceed Grid for WinForms forecolor in column depending on the value of data Reply To: forecolor in column depending on the value of data

User (Old forums)
Member
Post count: 23064

Each visual element in the grid (Row, Column, Cell, …) has some visual properties you can set (BackColor, ForeColor, Font, …)
To make the color depend on the data, you’ll have to catch the ValueChanged-event of the cell, and set the color there.<code>grid.DataRowTemplate.Cells[“myCell”].ValueChanged += new EventHandler(myCell_ValueChanged);
private void myCell_ValueChanged(object sender, EventArgs e)
{
Cell cell = sender as Cell;
if (…cell.Value…) // here you set your condition
cell.ForeColor = Color.Red;
else
cell.ResetForeColor();
}</code>

Imported from legacy forums. Posted by Tommy (had 286 views)