怎么在DataGrilView中增加数据列
请问怎么写代码?
private DataTable table = null; private void Form1_Load(object sender, EventArgs e) { DataBase data = new DataBase(); string sqlStr = "select * from Branch"; table = data.getDataTable(sqlStr); this.dataGridView1.DataSource = table; } /// <summary> /// 增加数剧列,从数据源添加 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { DataColumn colum = new DataColumn("数据源新加"); table.Columns.Add(colum); foreach (DataRow row in table.Rows) { row["数据源新加"] = "测试数据"; } }