我如何...在数据库中使用数据库以编程方式添加数据? [英] How do I...populate added programmatically row in datagridview with database ?
本文介绍了我如何...在数据库中使用数据库以编程方式添加数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想填充在datagridview中以编程方式添加数据(sql)或(访问数据库)的行..
用于以编程方式添加行的代码是:
i want to populate a row that added programmatically in datagridview with data (sql) or (access database) ..
the code used to add a row programmatically is :
DataGridViewColumn d1 = new DataGridViewComboBoxColumn();
DataGridViewColumn d2 = new DataGridViewComboBoxColumn();
DataGridViewColumn d3 = new DataGridViewTextBoxColumn();
DataGridViewColumn d4 = new DataGridViewTextBoxColumn();
DataGridViewColumn d5 = new DataGridViewTextBoxColumn();
DataGridViewColumn d6 = new DataGridViewTextBoxColumn();
DataGridViewColumn d7 = new DataGridViewTextBoxColumn();
d1.HeaderText = "barcode";
d2.HeaderText = "product name";
d3.HeaderText = "product type";
d4.HeaderText = "product price";
d5.HeaderText = "product amount";
d6.HeaderText = "product balance";
d7.HeaderText = "note";
if (this.dataGridView1.Columns.Count == 0)
{
dataGridView1.Columns.AddRange(d1, d2, d3, d4, d5, d6, d7);
}
dataGridView1.Rows.Add(1);
}
推荐答案
阅读这个简短的教程: http://www.dotnetperls.com/datagridview-tutorial [ ^ ],或咨询 MSDN [ ^ ]。
Read this short tutorial: http://www.dotnetperls.com/datagridview-tutorial[^], or consult MSDN[^].
这篇关于我如何...在数据库中使用数据库以编程方式添加数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文