Hello,everyone.
I want to ask something about DataGridView.Rows.Insert.
In a form there is a datagridview.
When right-click menu of a row in the datagridview,a new row is inserted before selectd row .
DataGridViewRow dgvNewRow = new DataGridViewRow();dgvNewRow.CreateCells(dgv);dgvNewRow.Cells[0].Value="11"dgDocDataList.Rows.Insert(dgvRow.Index + 1, dgvNewRow);//dgvRow is current selected row....//Here is setting values of other controls in current formdgvNewRow.Selected = true;
when running these codes ,sometimes there is a error:
System.InvalidOperationException: DataGridView You can not change the selected property before this object is added to the control.
From the error, i can see the new row is not successfully inserted,
but i do not how why.Is everybody has the same error?
thanks.