小弟相求……………………………………
怎样可以dataGridView的第一列中显示这一行是第几条记录?

解决方案 »

  1.   

    private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)        {                        if (e.ColumnIndex == -1 && e.RowIndex > -1)            {                StringFormat sf = new StringFormat(StringFormat.GenericDefault);                sf.Alignment = StringAlignment.Center;                e.PaintBackground(e.CellBounds, true);                e.Graphics.DrawString((e.RowIndex + 1).ToString(), this.Font,                    new SolidBrush(Color.Black), e.CellBounds,sf);                e.Handled = true;            }        }