Drag and Drop and vb.net

  • Thread starter Thread starter Microsoft News Groups
  • Start date Start date
M

Microsoft News Groups

does anyone know how to use the drag and drop feature with a richtextbox and
not have it wipe out all the text in the richtextbox when you drag and drop
your content in there?

TAI

Dave
 
Can you include the relevent code for what you are doing? Dragging an
object to the rtb? Dragging the rtb elsewhere? Dropping text onto the
rtb?
 
Hey Dan, here is the code. I would just like to be able to say drag
something ( some text ) from WordPad and drop it in my compiled application
in the richtextbox control. With this code it will drag and drop but it will
replace the text already in the richtextbox with the dragged code. I would
like to append it or put it anywhere in the richtextbox.

Is this possible?

Private Sub RichTextBox1_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragEnter
If (e.Data.GetDataPresent(DataFormats.Text)) Then
e.Effect = DragDropEffects.Copy

Else
e.Effect = DragDropEffects.Move
End If
End Sub
Private Sub RichTextBox1_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragDrop
RichTextBox1.Text = e.Data.GetData(DataFormats.Text)
' RichTextBox1.Text = e.Data.GetData(DataFormats.Text).ToString
End Sub

TIA
Dave
 
Back
Top