本文整理匯總了VB.NET中System.Windows.Forms.RichTextBox.AllowDrop屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET RichTextBox.AllowDrop屬性的具體用法?VB.NET RichTextBox.AllowDrop怎麽用?VB.NET RichTextBox.AllowDrop使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Windows.Forms.RichTextBox
的用法示例。
在下文中一共展示了RichTextBox.AllowDrop屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: New
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
richTextBox1.AllowDrop = True
End Sub
Private Sub listBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles listBox1.MouseDown
' Determines which item was selected.
Dim lb As ListBox = CType(sender, ListBox)
Dim pt As New Point(e.X, e.Y)
'Retrieve the item at the specified location within the ListBox.
Dim index As Integer = lb.IndexFromPoint(pt)
' Starts a drag-and-drop operation.
If index >= 0 Then
' Retrieve the selected item text to drag into the RichTextBox.
lb.DoDragDrop(lb.Items(index).ToString(), DragDropEffects.Copy)
End If
End Sub
Private Sub richTextBox1_DragEnter(ByVal sender As Object, ByVal e As DragEventArgs) Handles richTextBox1.DragEnter
' If the data is text, copy the data to the RichTextBox control.
If e.Data.GetDataPresent("Text") Then
e.Effect = DragDropEffects.Copy
End If
End Sub
Private Sub richTextBox1_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs) Handles richTextBox1.DragDrop
' Paste the text into the RichTextBox where at selection location.
richTextBox1.SelectedText = e.Data.GetData("System.String", True).ToString()
End Sub