本文介绍了向DataTable添加新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
csvData是绑定到DataGridView的DataTable。编译并运行没有错误。 。但刷新后,网格中不会出现新行。 。 。 ??是否缺少某些东西?
private void addNewRowButton_Click(object sender,EventArgs e)
{
csvData.NewRow();
DataGridView1.Refresh();
}
addNewRowButton的发件人是Form1。 。 。一个WINDOWS表单。
csvData is a DataTable bound to a DataGridView. Compiles & runs no errors . . but after refresh, no new row appears in grid . . . ?? Is there something missing?
private void addNewRowButton_Click(object sender, EventArgs e)
{
csvData.NewRow();
DataGridView1.Refresh();
}
The sender of the addNewRowButton is the Form1 . . . a WINDOWS form.
推荐答案
private void addNewRowButton_Click(object sender, EventArgs e)
{
csvData.NewRow();
// Provide Column values for the New Row.
DataGridView1.DataSource = csvData;
DataGridView1.DataBind();
}
这篇关于向DataTable添加新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!