zoukankan      html  css  js  c++  java
  • DataGridView 单元格背景颜色

    private void dataGridView1_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
            {
                if (e.RowIndex >= dataGridView1.Rows.Count - 1)
                    return;
                DataGridViewRow dgr = dataGridView1.Rows[e.RowIndex];
                try
                {
                    string[] Flag = dgr.Cells["Flag"].Value.ToString().Split('-');
                    DataGridViewCellStyle cstyle = new DataGridViewCellStyle();
                    cstyle.BackColor = Color.GreenYellow;

                    for (int i = 0; i < Flag.Length; i++)
                    {
                        if (Flag[i] == "1")
                        {

                            //dgr.DefaultCellStyle.ForeColor = Color.Blue;

                            dgr.Cells[0].Style = cstyle;
                        }
                        if (Flag[i] == "2")
                        {

                            //dgr.DefaultCellStyle.ForeColor = Color.Blue;
                            dgr.Cells[1].Style = cstyle;
                        }
                        if (Flag[i] == "3")
                        {

                            //dgr.DefaultCellStyle.ForeColor = Color.Blue;
                            dgr.Cells[2].Style = cstyle;
                        }
                        if (Flag[i] == "4")
                        {

                            //dgr.DefaultCellStyle.ForeColor = Color.Blue;

                            dgr.Cells[3].Style = cstyle;
                        }

                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

            }

  • 相关阅读:
    ubuntu下按安装lamp
    linux 一些简记
    编写shell脚本步骤
    C++ array vector 数组
    抓取网页扒图片相对路径改绝对路径
    静态html文件js读取url参数
    IE7的web标准之道——1:前言(兼目录) (很牛的CSS书籍)
    感谢放逐自由《博客园精华集》分类索引
    这篇文章证实了索引对于IN,LIKE的优化程度,顺便学会了怎么看看语耗费的时间
    命名空间“System”中不存在类型或命名空间名称“Linq”(是缺少程序集引用吗?)
  • 原文地址:https://www.cnblogs.com/ok519/p/1558084.html
Copyright © 2011-2022 走看看