C# winfrom datagridview 添加行數

 private void dataGridView_djmx_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            //自動編號,與數據無關
            Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,
                e.RowBounds.Location.Y,
                dataGridView_djmx.RowHeadersWidth - 4,
                e.RowBounds.Height);
            TextRenderer.DrawText(e.Graphics,
                (e.RowIndex + 1).ToString(),
                dataGridView_djmx.RowHeadersDefaultCellStyle.Font,
                rectangle,
                dataGridView_djmx.RowHeadersDefaultCellStyle.ForeColor,
                TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
        }

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