本文整理汇总了VB.NET中System.Windows.Forms.DataGridViewClipboardCopyMode枚举的典型用法代码示例。如果您正苦于以下问题:VB.NET DataGridViewClipboardCopyMode枚举的具体用法?VB.NET DataGridViewClipboardCopyMode怎么用?VB.NET DataGridViewClipboardCopyMode使用的例子?那么恭喜您, 这里精选的枚举代码示例或许可以为您提供帮助。
在下文中一共展示了DataGridViewClipboardCopyMode枚举的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: String
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Load
' Initialize the DataGridView control.
Me.DataGridView1.ColumnCount = 5
Me.DataGridView1.Rows.Add(New String() {"A", "B", "C", "D", "E"})
Me.DataGridView1.Rows.Add(New String() {"F", "G", "H", "I", "J"})
Me.DataGridView1.Rows.Add(New String() {"K", "L", "M", "N", "O"})
Me.DataGridView1.Rows.Add(New String() {"P", "Q", "R", "S", "T"})
Me.DataGridView1.Rows.Add(New String() {"U", "V", "W", "X", "Y"})
Me.DataGridView1.AutoResizeColumns()
Me.DataGridView1.ClipboardCopyMode = _
DataGridViewClipboardCopyMode.EnableWithoutHeaderText
End Sub
Private Sub CopyPasteButton_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles CopyPasteButton.Click
If Me.DataGridView1.GetCellCount( _
DataGridViewElementStates.Selected) > 0 Then
Try
' Add the selection to the clipboard.
Clipboard.SetDataObject( _
Me.DataGridView1.GetClipboardContent())
' Replace the text box contents with the clipboard text.
Me.TextBox1.Text = Clipboard.GetText()
Catch ex As System.Runtime.InteropServices.ExternalException
Me.TextBox1.Text = _
"The Clipboard could not be accessed. Please try again."
End Try
End If
End Sub