dataGridView常见操作

//不显示出dataGridView1的最后一行空白   

dataGridView1.AllowUserToAddRows = false;

//是否可以编辑

dataGridView1.ReadOnly = true;

//设置标头单元格 并赋值

int RowNumber=0;
foreach (DataGridViewRow row in this.dataGridView1.Rows)
{
row.HeaderCell.Value = RowNumber.ToString();

RowNumber++;
}

原文地址:https://www.cnblogs.com/qixiaolan/p/12752113.html