Home Forums WinForms controls Xceed Grid for WinForms Databind Backcolor Reply To: Databind Backcolor

User (Old forums)
Member
Post count: 23064

Yes this is possible. You need to subscribe to the AddingDataRow event of the GridControl, and set the cell BackColor in the event handler, by finding a way to make a corresponding between the value in the table and the Color structure.

e.g.:

//in Form_Load

gridControl1.AddingDataRow += new AddingDataRowEventHandler(gridControl1_AddingDataRow);

//Event handler

private void gridControl1_AddingDataRow(object sender, AddingDataRowEventArgs e)
{
//if the color value in the table is a string representing a color (e.g. “red”)
e.DataRow.Cells[ 0 ].BackColor = Color.FromName( e.DataRow.Cells[ 0 ].Value.ToString() );
}

Imported from legacy forums. Posted by André (had 2846 views)