Home Forums WinForms controls Xceed Grid for WinForms Coloring Rows based on conditions.. Reply To: Coloring Rows based on conditions..

User (Old forums)
Member
Post count: 23064

You can use the AddingDataRow event, and in the event handler, get and verify the value you want, and set the BackColor (and ForeColor if applicable) to what you want.

e.g.:

    private void Form1_Load( object sender, EventArgs e )
    {
      gridControl1.AddingDataRow += new AddingDataRowEventHandler( gridControl1_AddingDataRow );
    }

    void gridControl1_AddingDataRow( object sender, AddingDataRowEventArgs e )
    {
      string country = e.DataRow.Cells[ “Country” ].Value.ToString();
      if( country == “USA” )
      {
        e.DataRow.BackColor = Color.DeepPink;
      }
    }

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