dataGridView添加行號

private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            e.Graphics.DrawString(
                Convert.ToString(e.RowIndex + 1),
                e.InheritedRowStyle.Font,
                new SolidBrush(e.InheritedRowStyle.ForeColor),
                e.RowBounds.X +15,
                e.RowBounds.Y +5);

        }


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章