zoukankan      html  css  js  c++  java
  • DataGridView加上默认的序号

    DataGridView自动添加序号

    DataGridView找到RowPostPaint事件

      private void dg_item_info_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
            {
                SetDataGridViewIndex(this.dg_item_info, e);    
            }
            
         // 设置分页属性
    private static int pageIndex1 = 1; private static int pageSize1 = 10; /// <summary> /// 给GridView 添加默认序号 /// </summary> public static void SetDataGridViewIndex(DataGridView dgv, DataGridViewRowPostPaintEventArgs e) { 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 + ((pageIndex1 - 1) * pageSize1)).ToString(), dgv.RowHeadersDefaultCellStyle.Font, rectangle, dgv.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right); }
  • 相关阅读:
    django 如何重用app
    vim常用命令
    linux find grep
    linux su su-的区别
    linux定时任务crontab
    linux shell的单行多行注释
    python字符串的截取,查找
    gdb调试
    python字符转化
    python读写文件
  • 原文地址:https://www.cnblogs.com/besos/p/13328912.html
Copyright © 2011-2022 走看看