Winforms – Devexpress GridControl Format Conditions

devexpressgridviewwinforms

Is there anyone who has experience with the Devexpress GridControl.

I have a class which has a List of Objects in it. (This class is binded to the Grid).
This grid has a few columns to display the class.

I want a row to have another color when the list of objects.count is > 1

I've tried to like make an In-Place Editor Repository LookUpEdit item so I have the List of objects to set into a column.

DevExpress Family: Winforms

Best Answer

There are few methods that suit your needs. you can use the Appearance specific events that are more flexible.

Check the Customizing Appearances of Individual Rows and Cells on devExpress documentation.

Check this how can you change the appearance conditionally on the basis of some column value:

using DevExpress.XtraGrid.Views.Grid;

private void gridView1_RowStyle(object sender, 
DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e) {
   GridView View = sender as GridView;
   if(e.RowHandle >= 0) {
      string category = View.GetRowCellDisplayText(e.RowHandle, View.Columns["Category"]);
      if(category == "Beverages") {
         e.Appearance.BackColor = Color.Salmon;
         e.Appearance.BackColor2 = Color.SeaShell;
      }            
   }
}
Related Topic