zoukankan      html  css  js  c++  java
  • datagridview 单元格合并

    void dgResult_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
            {
                if (e.ColumnIndex == 0 && e.RowIndex != -1)
                {
                    using
                        (
                        Brush gridBrush = new SolidBrush(this.dgResult.GridColor),
                        backColorBrush = new SolidBrush(e.CellStyle.BackColor)
                        )
                    {
                        using (Pen gridLinePen = new Pen(gridBrush))
                        {
                            e.Graphics.FillRectangle(backColorBrush, e.CellBounds);
                            if (e.RowIndex < dgResult.Rows.Count - 1 &&
                            dgResult.Rows[e.RowIndex + 1].Cells[e.ColumnIndex].Value.ToString() !=
                            e.Value.ToString())
                                e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left,
                                e.CellBounds.Bottom - 1, e.CellBounds.Right - 1,
                                e.CellBounds.Bottom - 1);
                            e.Graphics.DrawLine(gridLinePen, e.CellBounds.Right - 1,
                                e.CellBounds.Top, e.CellBounds.Right - 1,
                                e.CellBounds.Bottom);
                            if (e.Value != null)
                            {
                                if (e.RowIndex > 0 &&
                                dgResult.Rows[e.RowIndex - 1].Cells[e.ColumnIndex].Value.ToString() ==
                                e.Value.ToString())
                                { }
                                else
                                {
                                    e.Graphics.DrawString((String)e.Value, e.CellStyle.Font,
                                        Brushes.Black, e.CellBounds.X + 2,
                                        e.CellBounds.Y + 5, StringFormat.GenericDefault);
                                }
                            }
                            e.Handled = true;
                        }
                    }
                }
            }
  • 相关阅读:
    Python join方法
    Python字符串capitalize center 方法
    Python int 中 add abs 方法
    Nginx Windows 安装启动
    Angularjs 首次加载显示{{}}
    Mysql 字符串截取
    Mysql 主键常用修改
    AES 加密256位 错误 java.security.InvalidKeyException: Illegal key size or default parameters
    Tocmat 启动错误 Port 8005 required by tomcat v7.0 server at localhost is already in use
    Socket IO Web实时推送
  • 原文地址:https://www.cnblogs.com/xinlang/p/1689978.html
Copyright © 2011-2022 走看看