DataGridView绑定行号

private void DataGridView_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
{
    foreach(DataGridViewRow row in DataGridView.Rows)
    {
        row.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight;
        row.HeaderCell.Value = (row.Index + 1).ToString();
    }
}
posted @ 2012-07-27 16:33  说不得  阅读(311)  评论(0编辑  收藏  举报