Murray Brown
asked on
VB.net Drag andDrop from RichTextBox (Automatically grab all text)
Hi
I am using the following code to drag data from a RichTextBox. At the moment I have to click into the RichTextBox
and manually select the text. How do I alter the code so that all the text is automatically included in the drag without
having to manually select it
Private Sub RichTextBox1_DragEnter(sen der As Object, e As System.Windows.Forms.DragE ventArgs) Handles RichTextBox1.DragEnter
If e.Data.GetDataPresent(Data Formats.St ringFormat ) Then
' Allow the drop.
e.Effect = DragDropEffects.Copy
Else
' Do not allow the drop.
e.Effect = DragDropEffects.None
End If
End Sub
Private Sub RichTextBox1_MouseDown(sen der As Object, e As System.Windows.Forms.Mouse EventArgs) Handles RichTextBox1.MouseDown
If e.Button = Windows.Forms.MouseButtons .Left And RichTextBox1.SelectionLeng th > 0 Then
RichTextBox1.DoDragDrop(Ri chTextBox1 .SelectedT ext, DragDropEffects.Copy)
End If
End Sub
I am using the following code to drag data from a RichTextBox. At the moment I have to click into the RichTextBox
and manually select the text. How do I alter the code so that all the text is automatically included in the drag without
having to manually select it
Private Sub RichTextBox1_DragEnter(sen
If e.Data.GetDataPresent(Data
' Allow the drop.
e.Effect = DragDropEffects.Copy
Else
' Do not allow the drop.
e.Effect = DragDropEffects.None
End If
End Sub
Private Sub RichTextBox1_MouseDown(sen
If e.Button = Windows.Forms.MouseButtons
RichTextBox1.DoDragDrop(Ri
End If
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER