أستخدم هذا
يمكنك أيضا الاستغناء عن المصفوفة والتعامل مع النص المنسوخ مباشرة
كود :
Imports System.Text.RegularExpressionsكود :
Try
If e.Control And (e.KeyCode = Keys.C) Then
Dim d As DataObject = DataGrid.GetClipboardContent()
Clipboard.SetDataObject(d)
e.Handled = True
ElseIf (e.Control And e.KeyCode = Keys.V) Then
Dim rowLines As String() = Clipboard.GetText(TextDataFormat.Text).Split({0}, StringSplitOptions.None)
Dim Cell As Byte
For Each x As Match In Regex.Matches(rowLines(0), "(\t|^).+?", RegexOptions.RightToLeft)
DataGrid(Cell, DataGrid.CurrentRow.Index).Value = x.Value
Cell += 1
Next
End If
Catch ex As Exception
'Log Exception
End Tryيمكنك أيضا الاستغناء عن المصفوفة والتعامل مع النص المنسوخ مباشرة
كود :
Dim Cell As Byte
For Each x As Match In Regex.Matches(Clipboard.GetText, "(\t|^).+?", RegexOptions.RightToLeft)
DataGrid(Cell, DataGrid.CurrentRow.Index).Value = x.Value
Cell += 1
Next