研究了一个下午,找到了Devexpress设置单元格的办法,先贴个图让大家看看效果
Devexpress 单元格设置
单元格字体有三个颜色,红、绿、黑
红色字体放大
底色两种类型,单一底色,渐变颜色底色
以下是代码
[C#] 纯文本查看 复制代码 gridView1.AddNewRow();
gridView1.SetRowCellValue(1, gridView1.Columns["Width"], "117");
gridView1.AddNewRow();
gridView1.SetRowCellValue(2, gridView1.Columns["Width"], "111");
gridView1.AddNewRow();
gridView1.SetRowCellValue(3, gridView1.Columns["Width"], "118");
gridView1.AddNewRow();
gridView1.SetRowCellValue(4, gridView1.Columns["Width"], "131");
gridView1.AddNewRow();
gridView1.SetRowCellValue(5, gridView1.Columns["Width"], "145");
gridView1.AddNewRow();
gridView1.SetRowCellValue(6, gridView1.Columns["Width"], "99");
gridView1.AddNewRow();
gridView1.SetRowCellValue(7, gridView1.Columns["Width"], "119");
DevExpress.XtraGrid.StyleFormatCondition redCondition = new DevExpress.XtraGrid.StyleFormatCondition();
redCondition.Appearance.Options.UseForeColor = true;
redCondition.Appearance.ForeColor = Color.Red;
redCondition.Appearance.Options.UseBackColor = true;
redCondition.Appearance.BackColor = Color.Yellow;
redCondition.Appearance.Options.UseFont = true;
redCondition.Appearance.Font = new Font("黑体", 13);
redCondition.Column = gridView1.Columns["Width"];
redCondition.Condition = DevExpress.XtraGrid.FormatConditionEnum.Expression;
redCondition.Expression = "[Width] > 120";
redCondition.Value1 = true;
DevExpress.XtraGrid.StyleFormatCondition blackCondition = new DevExpress.XtraGrid.StyleFormatCondition();
blackCondition.Appearance.Options.UseForeColor = true;
blackCondition.Appearance.ForeColor = Color.Black;
blackCondition.Appearance.Options.UseBackColor = true;
blackCondition.Appearance.BackColor = Color.Bisque;
blackCondition.Appearance.BackColor2 = Color.Green;
blackCondition.Column = gridView1.Columns["Width"];
blackCondition.Condition = DevExpress.XtraGrid.FormatConditionEnum.Expression;
blackCondition.Expression = "[Width] <= 120 And [Width] >= 115";
blackCondition.Value1 = true;
DevExpress.XtraGrid.StyleFormatCondition greenCondition = new DevExpress.XtraGrid.StyleFormatCondition();
greenCondition.Appearance.Options.UseForeColor = true;
greenCondition.Appearance.ForeColor = Color.Green;
greenCondition.Column = gridView1.Columns["Width"];
greenCondition.Condition = DevExpress.XtraGrid.FormatConditionEnum.Expression;
greenCondition.Expression = "[Width] <= 114";
greenCondition.Value1 = true;
this.gridView1.FormatConditions.AddRange(new DevExpress.XtraGrid.StyleFormatCondition[] {
redCondition,
blackCondition,
greenCondition
});
|