如何以编程方式向datagridview添加新行

如何以编程方式向datagridview添加新行,第1张

如何以编程方式向datagridview添加新行

你可以做:

DataGridViewRow row = (DataGridViewRow)yourDataGridView.Rows[0].Clone();row.Cells[0].Value = "XYZ";row.Cells[1].Value = 50.2;yourDataGridView.Rows.Add(row);

要么:

DataGridViewRow row = (DataGridViewRow)yourDataGridView.Rows[0].Clone();row.Cells["Column2"].Value = "XYZ";row.Cells["Column6"].Value = 50.2;yourDataGridView.Rows.Add(row);

另一种方式:

this.dataGridView1.Rows.Add("five", "six", "seven","eight");this.dataGridView1.Rows.Insert(0, "one", "two", "three", "four");

来自:http :
//msdn.microsoft.com/zh-
cn/library/system.windows.forms.datagridview.rows.aspx



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5064588.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-16
下一篇 2022-11-16

发表评论

登录后才能评论

评论列表(0条)

保存