Return to Snippet

Revision: 25734
at April 7, 2010 12:15 by pckujawa


Initial Code
private void w_Dgv_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
    // Add row numbers
    // Taken from "Pro C# 2008 and The .NET 3.5 Platform" pp. 807-808
    using (var brush = new SolidBrush(Color.Black))
    {
        e.Graphics.DrawString((e.RowIndex).ToString(),
                              e.InheritedRowStyle.Font, brush, e.RowBounds.Location.X + 15,
                              e.RowBounds.Location.Y + 4
            );
    }
}

Initial URL

                                

Initial Description
`w_Dgv` is the name of the DataGridView control.

Initial Title
Add index numbers to each row header in a DataGridView

Initial Tags
Net

Initial Language
C#