1、新建一个Form做测试,包含一个DataGridView,DataGridView有三列,分别是学号,姓名,分数表示一个期末考试分数表。
2、双击添加数据按钮,填写添加数据代码://some codeint index = this.dataGridView1.Rows.Add();this.dataGridView1.Rows[足毂忍珩index].Cells[0].Value = textBox1.Text;this.dataGridView1.Rows[index].Cells[1].Value = textBox2.Text;this.dataGridView1.Rows[index].Cells[2].Value = textBox3.Text;
3、点击运行,填写数据
4、点击添加即可添加一行数据
5、方法二:直接上代码:String[] values 屏顿幂垂= {textBox1.Text,textBox2.Text,textB泠贾高框ox3.Text };dataGridView1.Rows.Add(values);