?? fm_datagrid.vb
字號:
?Imports System.Data.OleDb
Imports Microsoft.VisualBasic
Imports System.Windows.Forms
Public Class FM_DataGrid
Dim pDataSet As DataSet
Dim pConn As OleDb.OleDbConnection
Public Sub New()
' 此調用是 Windows 窗體設計器所必需的。
InitializeComponent()
' 在 InitializeComponent() 調用之后添加任何初始化。
pConn = New OleDb.OleDbConnection
pDataSet = New DataSet
End Sub
Private Sub DataGridView1_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGridView1.KeyUp
If (e.Modifiers = Keys.Control) And (e.KeyCode = Keys.C) Then
' Clipboard.SetText(this.dvCustomer.GetClipboardContent().GetData(DataFormats.Text).ToString());
DataGridView1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithAutoHeaderText
' Clipboard.SetDataObject(Me.DataGridView1.GetClipboardContent())
Clipboard.SetText(Me.DataGridView1.GetClipboardContent().GetData(DataFormats.Text).ToString())
End If
If (e.Modifiers = Keys.Control) And (e.KeyCode = Keys.V) Then
Try
Dim str As String
str = Clipboard.GetText()
If str = "" Then Exit Sub
Dim lines As String()
lines = str.Split(Chr(13))
Dim line As String
Dim Cells As String()
Dim cell As String
Dim i As Int32 = Me.DataGridView1.CurrentCell.RowIndex - 1
Dim j0 As Int32 = Me.DataGridView1.CurrentCell.ColumnIndex
Dim j As Int32
For Each line In lines
i = i + 1
'If i < Me.DataGridView1.RowCount - 1 Then
' Me.DataGridView1.Rows.Add()
'End If
If line.Trim() = "" Then Continue For
j = j0
Cells = line.Split(Chr(Keys.Tab))
For Each cell In Cells
Me.DataGridView1.Rows(i).Cells(j).Value = cell
j = j + 1
Next
Next
Catch ex As Exception
End Try
End If
If (e.KeyCode = Keys.Delete) Then
Dim i As Int32
For i = 0 To Me.DataGridView1.SelectedCells.Count - 1
Me.DataGridView1.SelectedCells.Item(i).Value = ""
Next
End If
End Sub
End Class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -