zoukankan      html  css  js  c++  java
  • DataGridView 在 WinForms中应用不同的单元格式

    /// <summary>
    /// Set the cell background colour to make the ups and downs more visible.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void dgvData_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
        {
        DataGridView dgv = sender as DataGridView;
        if (dgv != null && e.RowIndex >= 0)
            {
            if (e.ColumnIndex > 0)
                {
                Color c;
                if (e.Value != null && e.Value is Int32)
                    {
                    int value = (int) e.Value;
                    if (value > 0)
                        {
                        c = Color.LightGreen;
                        }
                    else if (value < 0)
                        {
                        c = Color.Salmon;
                        }
                    else
                        {
                        c = dgv.DefaultCellStyle.BackColor;
                        }
                    e.CellStyle.BackColor = c;
                    }
                }
            }
        }
  • 相关阅读:
    函数
    循环练习
    循环结构
    分支结构
    C语言关键字
    进制编码
    MAC/Xcode简单操作命令
    Hibernate
    Hibernate
    Hibernate
  • 原文地址:https://www.cnblogs.com/zeroone/p/8933566.html
Copyright © 2011-2022 走看看