내가 System.InvalidOperationException이 처리되지 않은했다 동일한 데이터 그리드 뷰 컨트롤의 행 메시지 = 대처하면서 예외를 다음과 점점 오전에 속한다 "이미 제공된 행이 DataGridView 컨트롤에 속해 있습니다." 다음 사본 내가 빈 문자열로 번째 열을 유지하려는 붙여 넣기 방법에 붙여 넣기 동안 DataGridViewSelectedRowCollection예외 : 이미 제공된 행은 DataGridView 컨트롤
copy()
{
If (DataGridViewWorkGroupDetails.Rows.Count = 1) Then
Exit Sub
End If
Try
pasteMode = "copy"
currentRowCollection = DataGridViewWorkGroupDetails.SelectedRows
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, "frmworkgroup:copyRowCollectionError")
End Try
}
로 붙여 넣기 방법
paste()
{
Dim row As DataGridViewRow
Dim myRow As DataGridViewRow
For Each row In currentRowCollection
myRow = row
myRow.Cells.Item(1).Value = String.Empty
DataGridViewWorkGroupDetails.Rows.Insert(DataGridViewWorkGroupDetails.Rows.Count - 1, myRow)
Next
}
에 currentRowCollection에서 행을 선택하는 복사 방법입니다. 한 datagridview에서 다른 행으로 복사 할 때 작동하지만 동일한 datagridview로 복사하면 예외가 추가됩니다. 제공된 행이 이미 DataGridView 컨트롤에 속해 있습니다.
당신이 나에게 그것 vb.net ..There에서 작동하지 않는 그 –
에 대한 샘플 코드를 제공시겠습니까 작동합니다은에 대한 NewRow() 메소드입니다 위 라인에서 사용 된 datagridview myRow = DataGridViewWorkGroupDetails.NewRow(); –