• 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;
                        }
                    }
                }
            }
  • 相关阅读:
    java接入钉钉机器人(带源码)
    使用java做一个能赚钱的微信群聊机器人(2020年基于PC端协议最新可用版)
    侠说java8--Stream流操作学习笔记,都在这里了
    Elasticsearch调优篇-慢查询分析笔记
    网络探测和抓包工具 wireshark
    window10远程ubuntu18.04
    springdataJPA mysql myisam innodb
    命令集
    java tmpdir 启动 kafka 命令行
    java jar 启动命令
  • 原文地址:https://www.cnblogs.com/xinlang/p/1689978.html
Copyright © 2020-2023  润新知