Wednesday, May 29, 2013

How to set the background color of a grid column header panel, DevExpress?

If you want to set the background color of a XtraGrid control from DevExpress controls you might get into some problems. Why? Because you can indeed find property Appearance.HeaderPanel.BackColor, then you set it and however no influence on grid. Why? Because you have to make another set :) But is not specified anywhere in info places.
So how do solve this?
In order to set background color of a GridControl, winforms you have to:
-go to gridControl and set Style to Flat;
-set UseDefaultLookAndFeel to False

-go to gridview and set Appearance.HeaderPanel.BackColor - your color (this will automatically set useBackColor to true, also)

Otherwise if you want to set it by code you may use this:

  gridControl1.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Flat;
  gridControl1.LookAndFeel.UseDefaultLookAndFeel = false; 

  gridView1.Appearance.HeaderPanel.Options.UseBackColor = true;
  gridView1.Appearance.HeaderPanel.BackColor = System.Drawing.Color.Red;
If this helped you, go ahead and share :)