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

admin   ·   发表于 3个月前   ·   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 条回复   |  直到 3个月前 | 179 次浏览
登录后才可发表内容