dataGridView如何才能让每行前边加上系统给的序号呢?我说的不是数据库中的自动编号,是每行前边的序号123456789

解决方案 »

  1.   

    参看
    http://www.codeproject.com/books/PresentDataDataGridView.asp中的“Utilizing Cell-Oriented Grid Features”这部分。
      

  2.   

    DATAGRIDVIEW 增加一个RowPostPaint 事件
     private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
            {
                using (SolidBrush b = new SolidBrush(dataGridView1.RowHeadersDefaultCellStyle.ForeColor))
                {
                    e.Graphics.DrawString(e.RowIndex.ToString(System.Globalization.CultureInfo.CurrentUICulture), e.InheritedRowStyle.Font, b, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4);
                }
            }