111,126
社区成员
发帖
与我相关
我的任务
分享dataGridView1.Rows[dataGridView1.CurrentRow].Cells["字段名"]private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
DataTable dt = new DataTable();
dt = dataGridView1.DataSource as DataTable;
DataTable table = GetTable(); //从数据库读出来的
for (int i = 0; i < table.Rows.Count; i++)
{
dt.Rows.Add(table.Rows[i].ItemArray);
}
dataGridView1.DataSource = dt;
}
private void dataGridView2_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
ds.Tables["table"].Rows.Add();//这里把你后来绑定的数据追加进去
dataGridView2.DataSource = ds.Tables["table"].DefaultView;
}