2013-05-21 65 views

回答

1

您可以使用DataGridView.Rows.Insert(int rowIndex, DataGridViewRow dataGridViewRow),它可以插入特定/所需索引處的DataRow。

MSDN

Overloads for Insert Method

+0

我使用此代碼通過鼠標點擊.....私人無效dgvPDescription_CellMouseClick(對象發件人,DataGridViewCellMouseEventArgs E) { INT當前的兩行之間的行添加更多細節= dgvPDescription.CurrentCell.RowIndex; MessageBox.Show(current.ToString()); dgvPDescription.Rows.Insert(current + 1,dgvPDescription); }不幸的是我得到了錯誤「」當控件是數據綁定時,行不能以編程方式添加到DataGridView的行集合中。「」 –

+0

@AnoopNarayan您必須將該行添加到您的'Datasource'並將其重新綁定 – V4Vendetta

相關問題