我想在datagridview中创建一个表并添加一个文本。我尝试了很多代码,但它不起作用。
这里输出甚至我编程添加一些文字:
从购物车表单添加列:
DataTable table = new DataTable();
private void domainUpDown1_SelectedItemChanged(object sender, EventArgs e)
{
table.Columns.Add("BOOK", typeof(string));
table.Columns.Add("Author", typeof(string));
table.Columns.Add("Price", typeof(double));
table.Columns.Add("Quantity", typeof(int));
dataGridView1.DataSource = table;
}
并添加书籍形式的行:
private void button6_Click(object sender, EventArgs e){
DataTable TBL = new DataTable();
TBL.Rows.Add(BName2.Text);
TBL.Rows.Add(AName2.Text);
TBL.Rows.Add(PRC2.Text);
Ct.dataGridView1.DataSource = TBL;
}
请有人帮帮我。