1. Drag a Gridcontrol control on the form
2. Add three columns are Bgcolor,bgcolor2, fontcolor respectively display cell color cells gradient color cell font Color
Public partial class Form1:form {public Form1 () {InitializeComponent (); private void Form1_Load (object sender, EventArgs e) {list<object> List = new List<obj Ect> (); List. Add (New {BgColor = one, BgColor2 = n, fontcolor = 13}); List. Add (New {BgColor = BgColor2, fontcolor = 23}); List. Add (New {BgColor = +, BgColor2 = +, FontColor = 33}); Gridcontrol1.datasource = list; private void Gridview1_rowcellstyle (object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e) {GridView View = sender as GridView; if (E.column.fieldname = = "BgColor")//Set Background {//int Pointid = (Gridview1.getrow (e.rowhandle) as OB ject). BgColor; E.appearance.backcolor = color.red; } else if (E.column.fieldname = = "BgColor2")//Set gradient background {//int PoinTID = (Gridview1.getrow (e.rowhandle) as Object). BgColor; E.appearance.backcolor = color.red; E.appearance.backcolor2 = Color.FromArgb (255, 255, 255); } else if (E.column.fieldname = = "FontColor")//Set font Color {//int Pointid = (gridview1.get Row (E.rowhandle) as Object). BgColor; E.appearance.forecolor = Color.red;//color.fromargb (42, 173, 231); } } }
Devgridcontrol cell background color and cell text color settings