zoukankan      html  css  js  c++  java
  • [唐胡璐] winform中改变DataGridView中符合条件的字体的颜色

    把QTP Report中的运行结果状态根据结果显示为不同的颜色:

    private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) 
           { 
               if (e.RowIndex < 0) 
                   return; 
     
               if (e.ColumnIndex == dataGridView1.Columns["CaseStatus"].Index) 
               { 
                   if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "Passed") 
                   { 
                       e.CellStyle.ForeColor = Color.Green; 
                   } 
                   else if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "Failed") 
                   { 
                       e.CellStyle.ForeColor = Color.Red; 
                   } 
                   else if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "Warning") 
                   { 
                       e.CellStyle.ForeColor = Color.Goldenrod; 
                   } 
                   else if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "No Run") 
                   { 
                       e.CellStyle.ForeColor = Color.Gray; 
                   } 
               } 
           }
  • 相关阅读:
    OpenCV/python读取,显示,保存图像
    机器学习的基本分类
    Qt Designer常用部件介绍
    C#数据类型列表
    SQL-Base 函数
    SQl 基本函数
    SQL 插入数据
    SQL-Base 用表组织数据
    SQLserver的基本用法
    C#MyBank(自己的看法,转账有点小问题)
  • 原文地址:https://www.cnblogs.com/yongfeiuall/p/4134164.html
Copyright © 2011-2022 走看看