DataGridView显示行号

 


Private Sub DataGridView1_RowPostPaint(sender As Object, e As System.Windows.Forms.DataGridViewRowPostPaintEventArgs) Handles DataGridView1.RowPostPaint
    Dim Rectangle As System.Drawing.Rectangle = New System.Drawing.Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, DataGridView1.RowHeadersWidth - 4, e.RowBounds.Height)
    System.Windows.Forms.TextRenderer.DrawText(e.Graphics,
       (e.RowIndex + 1).ToString(),
        DataGridView1.RowHeadersDefaultCellStyle.Font,
        Rectangle,
        DataGridView1.RowHeadersDefaultCellStyle.ForeColor,
        System.Windows.Forms.TextFormatFlags.HorizontalCenter + System.Windows.Forms.TextFormatFlags.VerticalCenter)
End Sub

 

 

posted @ 2020-02-07 22:20  rf8862  阅读(122)  评论(0编辑  收藏  举报