动态改变Gridview中某行的颜色

直接上代码:

 

 private void gridView1_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)

        {

            DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView;

            if (e.RowHandle >= 0)

            {

                string status = view.GetRowCellDisplayText(e.RowHandle, view.Columns["Charge"]);

                if (status == "60")

                {

                    e.Appearance.BackColor = Color.Green;

                }

                else if (status == "40")

                {

                    e.Appearance.BackColor = Color.Yellow;
                }
                else
                {
                    e.Appearance.BackColor = Color.Red;
                }
            }
        }

你可能感兴趣的:(object,String)