Winform中Grid跨行复制一列

时间:2023-03-08 21:30:23
Winform中Grid跨行复制一列
 Private Sub DataCopyToGrid()
'判断剪切板中是否存在内容
If Clipboard.ContainsText Then
Dim str = Clipboard.GetText()
Dim array = Strings.Split(str, vbCrLf)
Dim selerow As Integer = Me.Grid.CurrentCell.RowIndex
Dim selecom As Integer = Me.Grid.CurrentCell.ColumnIndex If array IsNot Nothing And selerow >= And selecom = Then
Dim j =
For i = selerow To Me.Grid.Rows.Count -
If j > array.Length - Then
Exit For
End If If Me.Grid.Rows(i).Cells(selecom).ReadOnly = False Then
Me.Grid.Rows(i).Cells(selecom).Value = array(j)
j = j +
End If
Next
End If
End If
End Sub

在Keydown事件中捕获Ctrl+V按键(e.Control And e.KeyCode = Keys.V)