当前位置:编程学习 > C#/ASP.NET >>

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

小弟相求……………………………………
怎样可以dataGridView的第一列中显示这一行是第几条记录? --------------------编程问答-------------------- 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;

            }

        } --------------------编程问答--------------------
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,