zoukankan      html  css  js  c++  java
  • winform中datagridview事件RowPrePaint中类似与webform中的gridview的rowdatabound事件

    我查了一下,ydsunny(小强)   (   )是web的解决方法,在winform里,DataGridView没有RowDataBound事件,如果在winform里,如下修改: 
    
    
    private   void   dataGridView1_RowPrePaint(object   sender,   DataGridViewRowPrePaintEventArgs   e) 
                    { 
                            if   (e.RowIndex   > =   dataGridView1.Rows.Count   -   1) 
                                    return; 
                            DataGridViewRow   dgr   =   dataGridView1.Rows[e.RowIndex]; 
                            try 
                            { 
                                    if   (dgr.Cells[ "列名 "].Value.ToString()   ==   "比较值 ") 
                                    { 
                                            dgr.DefaultCellStyle.ForeColor   =   设置的颜色; 
                                    } 
                            } 
                            catch   (Exception   ex) 
                            { 
                                    MessageBox.Show(ex.Message); 
                            } 
                    }
    
  • 相关阅读:
    学习进度表
    第八次日志
    第七次日志
    第六次日志
    第五次日志
    第四次日志
    第一次日志
    第三次日志
    第二次日志
    学习进度表
  • 原文地址:https://www.cnblogs.com/xiaofengfeng/p/2036721.html
Copyright © 2011-2022 走看看