DataGridView动态添加新行的两种方法
生活随笔
收集整理的這篇文章主要介紹了
DataGridView动态添加新行的两种方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
簡單介紹如何為DataGridView控件動態添加新行的兩種方 法:
方法一:
int index=this.dataGridView1.Rows.Add();
this.dataGridView1.Rows[index].Cells[0].Value = "1";?
this.dataGridView1.Rows[index].Cells[1].Value = "2";?
this.dataGridView1.Rows[index].Cells[2].Value = "監聽";
方法二:
DataGridViewRow row = new DataGridViewRow();
DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
textboxcell.Value = "aaa";
row.Cells.Add(textboxcell);
DataGridViewComboBoxCell comboxcell = new DataGridViewComboBoxCell();
row.Cells.Add(comboxcell);
dataGridView1.Rows.Add(row);
轉載于:https://www.cnblogs.com/dxmfans/p/9434903.html
總結
以上是生活随笔為你收集整理的DataGridView动态添加新行的两种方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 共享单车为啥频频涨价?听听专家怎么说 高
- 下一篇: 中元节《纸嫁衣4》首发大面积故障:无法进