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;
                        }
                    }
                }
            }
  • 相关阅读:
    Anaconda-navigator 打不开的解决方法(亲测有效!)
    Python3.7安装keras和TensorFlow的教程图解
    win10环境下使用anaconda安装opencv
    windows环境下的Anaconda安装与OpenCV机器视觉环境搭建
    各种工具汇总(20210702更新)
    关于文章致谢
    公共数据库信息汇总(20210709更新)
    关于摆脱痛苦
    pip 本地安装 python 包
    报错Error: Sorted input specified, but the file file.bedgraph has the following out of order record解决方案
  • 原文地址:https://www.cnblogs.com/xinlang/p/1689978.html
Copyright © 2011-2022 走看看