gpt4 book ai didi

c# - 以编程方式向 datagridview 添加新行

转载 作者:行者123 更新时间:2023-11-30 16:41:59 25 4
gpt4 key购买 nike

我尝试向 datagridview 添加新行,我尝试使用此代码

DataGridViewRow row = (DataGridViewRow)dgv_OfferTerms.Rows[0].Clone();
row.Cells[0].Value = cond.Id;
row.Cells[1].Value = cond.Name;
row.Cells[2].Value = cond.Title;
row.Cells[3].Value = cond.Description;
dgv_OfferTerms.Rows.Add(row);

没用所以我试试这个

dgv_OfferTerms.Rows.Add(cond.Id,cond.Name,cond.Title,cond.Description);

没用如何向 datagridview 添加新行??

最佳答案

这些代码可能对您有帮助:

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

或:

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

引用自: https://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.rows.aspx

关于c# - 以编程方式向 datagridview 添加新行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47497211/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com