Gridview 单元格通过循环和在 gridview 单元格上设置的值自动添加
int txt1 = Convert.ToInt32(textBox1.Text);
int txt2 = Convert.ToInt32(textBox2.Text);
for (int i = txt1; i < txt2 + 1; i++)
{
MessageBox.Show(""+i);
for (int j = 0; j < dataGridView1.Rows.Count+1; j++)
{
dataGridView1.Rows[j].Cells["id"].Value = i.ToString();
}
}
private void Form1_Load(object sender, EventArgs e)
{
this.dataGridView1.Columns.Add("id", "ID");
}
我正在尝试这样检查此链接。