如下:
===================================================================
   private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
 Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,
              e.RowBounds.Location.Y,
              grid.RowHeadersWidth,
              e.RowBounds.Height);            TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1 + "/" + grid.Rows.Count).ToString(),
                grid.RowHeadersDefaultCellStyle.Font,
                rectangle,
                grid.RowHeadersDefaultCellStyle.ForeColor,
                TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter);
        }===============================================================因为所有的DataGridView都会用到这个事件,我想把它做成Public,关键是参数e用什么来传进去呢?

解决方案 »

  1.   

    public void RowPostPaint( object sender, DataGridViewRowPostPaintEventArgs e )
    {
       DataGridView grid = ( DataGridView )sender ;Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,
    e.RowBounds.Location.Y,
    grid.RowHeadersWidth,
    e.RowBounds.Height);TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1 + "/" + grid.Rows.Count).ToString(),
    grid.RowHeadersDefaultCellStyle.Font,
    rectangle,
    grid.RowHeadersDefaultCellStyle.ForeColor,
    TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter);
    }private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
    {
    RowPostPaint( sender , e );
    }