GridView改变单行背景色

 

            DevExpress.XtraGrid.StyleFormatCondition StyleFormatCondition1 = new DevExpress.XtraGrid.StyleFormatCondition();
            StyleFormatCondition1.Appearance.BackColor = System.Drawing.Color.Red;
            StyleFormatCondition1.Appearance.BackColor2 = Color.White;
            StyleFormatCondition1.Appearance.Options.UseBackColor = true;
            //StyleFormatCondition1.ApplyToRow = true;
            StyleFormatCondition1.Column = MainView.Columns[0];
            StyleFormatCondition1.Condition = DevExpress.XtraGrid.FormatConditionEnum.Equal;
            StyleFormatCondition1.Value1 = "wyl2";
            MainView.FormatConditions.AddRange(new DevExpress.XtraGrid.StyleFormatCondition[] { StyleFormatCondition1 });

也可以:

在GridControl中的Gridview的CustomDrawCell写如下代码private void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
                if (e.RowHandle==1)
                {

                    //字体颜色,也可改变背景颜色等属性
                    e.Appearance.ForeColor = Color.Red;
                }
               if (e.RowHandle==3)
                {

                    //字体颜色,也可改变背景颜色等属性
                    e.Appearance.ForeColor = Color.Red;
                }

        } (其他DX控件都有此类似方法来改变属性)

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/david04310711323/archive/2008/07/21/2684144.aspx

posted @ 2010-12-10 09:01  sweetjian  阅读(3937)  评论(0编辑  收藏  举报