Posted By

pckujawa on 04/07/10


Tagged

gui Net


Versions (?)

Add index numbers to each row header in a DataGridView


 / Published in: C#
 

w_Dgv is the name of the DataGridView control.

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

Report this snippet  

You need to login to post a comment.