Member 3892343 Ответов: 3

копирование выбранных строк в другой элемент


Я хочу скопировать выбранные строки из INE datagrid во вторую, этот код копирует только индексный номер :
For Each drr As DataGridViewRow In DataGridView1.SelectedRows

    Form4.DataGridView1.Rows.Add(drr.Clone)

Next


Либо ты помочь

3 Ответов

Рейтинг:
1

DamithSL

Ты рядом, делай как ниже

For Each drr As DataGridViewRow In DataGridView1.SelectedRows
   Dim row As DataGridViewRow = CType(drr.Clone(), DataGridViewRow)
   For i As Int32 = 0 To drr.Cells.Count - 1
      row.Cells(i).Value = drr.Cells(i).Value
   Next
   Form4.DataGridView1.Rows.Add(row)
Next


Рейтинг:
0

Hanish Kapoor

'Hope This helps DGV1 is the datagridview
'To copy Row
Private Sub CopyButton_Click(sender As System.Object, e As System.EventArgs) Handles CopyButton.Click
    CopyRowIndex = DGV1.CurrentRow.Index
End Sub

'To Paste Row
Private Sub PasteButton_Click(sender As System.Object, e As System.EventArgs) Handles PasteButton.Click
    PasteRowIndex = DGV1.CurrentRow.Index
    For index As Int32 = 0 To DGV1.ColumnCount - 1
        DGV1.Rows(CInt(PasteRowIndex)).Cells(index).Value = DGV1.Rows(CInt(CopyRowIndex)).Cells(index).Value
    Next

End Sub

'To Duplicate Rows
Private Sub DuplicateButton_Click(sender As System.Object, e As System.EventArgs) Handles DuplicateButton.Click
    CopyRowIndex = DGV1.CurrentRow.Index
    DGV1.Rows.Add()
    DuplicateRowIndex = DGV1.Rows.Count - 1
    For index As Int32 = 0 To DGV1.ColumnCount - 1
        DGV1.Rows(CInt(DuplicateRowIndex)).Cells(index).Value = DGV1.Rows(CInt(CopyRowIndex)).Cells(index).Value
    Next
End Sub


Richard Deeming

Опоздал на три года.

Member 13724938

не для меня