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);
}
}
爲datagridView添加行號
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.