给数据窗口每行前添加序号

admin   ·   发表于 7个月前   ·   C sharp

 private void uiDataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)

        {

            SolidBrush b = new SolidBrush(this.uiDataGridView1.RowHeadersDefaultCellStyle.ForeColor);

            e.Graphics.DrawString((e.RowIndex + 1).ToString(System.Globalization.CultureInfo.CurrentUICulture), this.uiDataGridView1.DefaultCellStyle.Font, b, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4);

        }

0 Reply   |  Until 7个月前 | 387 View
LoginCan Publish Content