[DevExpress]GridControl单元格背景色和单元格文字颜色设置

Posted 厦门德仔

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[DevExpress]GridControl单元格背景色和单元格文字颜色设置相关的知识,希望对你有一定的参考价值。

1.拖一个gridControl控件在窗体上
2.添加三列 分别是 BgColor,BgColor2 , FontColor 分别显示单元格颜色 单元格渐变颜色 单元格字体颜色

 public partial class Form1 : Form
    
        public Form1()
        
            InitializeComponent();
        
        private void Form1_Load(object sender, EventArgs e)
        
            List<object> list = new List<object>();
            list.Add(new  BgColor = 11, BgColor2 = 12, FontColor = 13 );
            list.Add(new  BgColor = 21, BgColor2 = 22, FontColor = 23 );
            list.Add(new  BgColor = 31, BgColor2 = 32, 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")//设背景
            
                //int pointID = (gridView1.GetRow(e.RowHandle) as object).BgColor;
                e.Appearance.BackColor = Color.Red;
            
            else if (e.Column.FieldName == "BgColor2")//设渐变背景
            
                //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")//设字体颜色
            
                //int pointID = (gridView1.GetRow(e.RowHandle) as object).BgColor;
                e.Appearance.ForeColor = Color.Red;//Color.FromArgb(42, 173, 231);
            
        
    

以上是关于[DevExpress]GridControl单元格背景色和单元格文字颜色设置的主要内容,如果未能解决你的问题,请参考以下文章

[DevExpress]gridcontrol中单元格属性设置为RepositoryItemCheckEdit

DevExpress GridControl

C# DevExpress 窗体控件 gridcontrol 获取单元格显示区域的矩形, 然后得到坐标的方法 是啥?

在Devexpress 的GridControl控件里,单元格的显示问题

gridControl根据值合并单元格

有谁用过DevExpress.Xtragrid中的GridControl控件的,麻烦高手们告诉我怎么样做