zoukankan      html  css  js  c++  java
  • DataGridView改变行颜色

     例一:

    private void dataGridView1_RowPrePaint(object   sender,   DataGridViewRowPrePaintEventArgs   e)
    {
        
    if(e.RowIndex < dataGridView1.Rows.Count -1)
        {
            DataGridViewRow dgrSingle 
    = dataGridView1.Rows[e.RowIndex];
            
    try
            {
                
    if(dgrSingle.Cells["列名"].Value.ToString().Contains("比较值"))
                {
                    dgrSingle.DefaultCellStyle.ForeColor 
    = Color.Red;
                }
            }
            
    catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }

     例二:

    private void dataGridView1_CellPainting(object sender,DataGridViewCellPaintingEventArgs e)
    {
        
    if(e.RowIndex == 2 && e.ColumnIndex> =0)
        {
            
    using(SolidBrush brush = new SolidBrush(Color.Red))
            {
                e.Graphics.FillRectangle(brush,e.CellBounds);
                e.Handled 
    = true;
            }
        }
    }
  • 相关阅读:
    全景拼接
    krpano之字幕添加
    UML之时序图
    krpano之语音介绍
    小工具之录音(文字转语音)
    动态生成按钮的点击事件绑定
    登录之简单验证码
    登录之md5加密
    redis与mysql数据同步
    Sql Server 主从数据库配置
  • 原文地址:https://www.cnblogs.com/zhangpengshou/p/1783213.html
Copyright © 2011-2022 走看看