C# DataGrid 控件在winform里显示行号
生活随笔
收集整理的這篇文章主要介紹了
C# DataGrid 控件在winform里显示行号
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#region 行繪制事件 ,為DataGridView每行寫上序號/// <summary>/// 行繪制事件 ,為DataGridView每行寫上序號/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void dataGridView_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e){Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, this.dataGridView.RowHeadersWidth - 4, e.RowBounds.Height);TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(),this.dataGridView.RowHeadersDefaultCellStyle.Font,rectangle, this.dataGridView.RowHeadersDefaultCellStyle.ForeColor,TextFormatFlags.VerticalCenter | TextFormatFlags.Right);}#endregion
轉載于:https://www.cnblogs.com/pukuimin/archive/2013/02/06/2988071.html
總結
以上是生活随笔為你收集整理的C# DataGrid 控件在winform里显示行号的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 6.00 Introduction to
- 下一篇: SQL 2005/2008 清空收缩日志