110,538
社区成员
发帖
与我相关
我的任务
分享
DataTable DT = new DataTable();
DT.TableName = "b";
DT.Columns.Add(new DataColumn("code", typeof(string)));
DT.Columns.Add(new DataColumn("ver", typeof(string)));
DT.Columns.Add(new DataColumn("name", typeof(int)));
DT.Rows.Add('1', '1', 1);//添加行
DT.Rows.Add('2', '2', 1);//添加行
DT.Rows.Add('3', '3', 1);//添加行
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
DataTable table = new DataTable();
table.TableName = "b";
table.Columns.Add(new DataColumn("code", typeof(string)));
table.Columns.Add(new DataColumn("ver", typeof(string)));
table.Columns.Add(new DataColumn("name", typeof(int)));
table.Rows.Add('1', '1', 1);//添加行
table.Rows.Add('2', '2', 1);//添加行
table.Rows.Add('3', '3', 1);//添加行
this.dataGridView1.DataSource = table;
}
private void button1_Click(object sender, EventArgs e)
{
DataTable table = dataGridView1.DataSource as DataTable;
table.Rows.Cast<DataRow>().ToList().ForEach(row => row["ver"] = "a" + row["ver"].ToString());
}