Esempio n. 1
0
 static void UIMessage_RowPostPaint(object sender, System.Windows.Forms.DataGridViewRowPostPaintEventArgs e)
 {
     System.Windows.Forms.DataGridView grd = ((System.Windows.Forms.DataGridView)sender);
     using (System.Drawing.SolidBrush b = new System.Drawing.SolidBrush(grd.RowHeadersDefaultCellStyle.ForeColor))
     {
         e.Graphics.DrawString((e.RowIndex + 1).ToString(System.Globalization.CultureInfo.CurrentUICulture), e.InheritedRowStyle.Font, b, e.RowBounds.Location.X + 8, e.RowBounds.Location.Y + 4);
     }
 }
Esempio n. 2
0
 public static void SetRowNumber(System.Windows.Forms.DataGridView dgv, System.Windows.Forms.DataGridViewRowPostPaintEventArgs e)
 {
     System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, dgv.RowHeadersWidth - 4, e.RowBounds.Height);
     System.Windows.Forms.TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(),
                                                dgv.RowHeadersDefaultCellStyle.Font, rectangle,
                                                dgv.RowHeadersDefaultCellStyle.ForeColor,
                                                System.Windows.Forms.TextFormatFlags.VerticalCenter | System.Windows.Forms.TextFormatFlags.Right);
 }