zoukankan      html  css  js  c++  java
  • C# DataGridView 在最左侧显示行号方法

    代码:

            private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
            {
                DataGridView dgv = sender as DataGridView;
                Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,
                                                    e.RowBounds.Location.Y,
                                                    dgv.RowHeadersWidth - 4,
                                                    e.RowBounds.Height);
    
    
                TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(),
                                        dgv.RowHeadersDefaultCellStyle.Font,
                                        rectangle,
                                        dgv.RowHeadersDefaultCellStyle.ForeColor,
                                        TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
            }

    效果:

  • 相关阅读:
    8.5
    8.12
    8.11
    8.14
    8.15
    8.18
    8.16
    8.20
    Android新版NDK环境配置(免Cygwin)
    在Windows7上搭建Cocos2d-x win32开发环境
  • 原文地址:https://www.cnblogs.com/swjian/p/9046034.html
Copyright © 2011-2022 走看看