原创  为datagridView添加行号 收藏

        private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)

        {           

           Color color = dataGridView1.RowHeadersDefaultCellStyle.ForeColor;

           if (dataGridView1.Rows[e.RowIndex].Selected)

                color = dataGridView1.RowHeadersDefaultCellStyle.SelectionForeColor;

           else

                color = dataGridView1.RowHeadersDefaultCellStyle.ForeColor;



           using (SolidBrush b = new SolidBrush(color))

            {

                e.Graphics.DrawString((e.RowIndex+1).ToString(), e.InheritedRowStyle.Font, b, e.RowBounds.Location.X+20, e.RowBounds.Location.Y+6);

            }

       

        }

发表于 @ 2008年07月04日 17:12:00 | 评论( loading... ) | 编辑| 举报| 收藏

旧一篇:c#用mcisendstring API播放mp3 | 新一篇:c# 滚动字幕的实现

  • 发表评论
  • 评论内容:
  •  
Copyright © baihe_591
Powered by CSDN Blog