Winform中Grid跨行复制一列

 1 Private Sub DataCopyToGrid()
 2         '判断剪切板中是否存在内容
 3         If Clipboard.ContainsText Then
 4             Dim str = Clipboard.GetText()
 5             Dim array = Strings.Split(str, vbCrLf)
 6             Dim selerow As Integer = Me.Grid.CurrentCell.RowIndex
 7             Dim selecom As Integer = Me.Grid.CurrentCell.ColumnIndex
 8 
 9             If array IsNot Nothing And selerow >= 0 And selecom = 4 Then
10                 Dim j = 0
11                 For i = selerow To Me.Grid.Rows.Count - 1
12                     If j > array.Length - 1 Then
13                         Exit For
14                     End If
15 
16                     If Me.Grid.Rows(i).Cells(selecom).ReadOnly = False Then
17                         Me.Grid.Rows(i).Cells(selecom).Value = array(j)
18                         j = j + 1
19                     End If
20                 Next
21             End If
22         End If
23     End Sub

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

原文地址:https://www.cnblogs.com/Sunflower-/p/6170638.html