How to copy One row to another row in gridview

前端 未结 2 1769
逝去的感伤
逝去的感伤 2021-01-27 06:23

Using VB.Net

I want to Copy one row data to another row.

I am using checkbox in the gridview, if i clicked the checkbox and press button then selected row copy t

2条回答
  •  Happy的楠姐
    2021-01-27 07:04

    '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
    

提交回复
热议问题