Results 1 to 2 of 2

Thread: drag drop formated text into rtf box

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2003
    Posts
    11

    drag drop formated text into rtf box

    Hi All,

    Could someone help me out please. I am trying to enable drag and drop operations into richtextbox control and I want to be able to drag and drop formated text (from word headings, bold fonts etc...) I've managed to drag and drop text but all the formating is getting lost

    VB Code:
    1. Me.RichTextBox1.AllowDrop = True
    2.  Me.RichTextBox1.AutoWordSelection = True
    3.  
    4. Private Sub RichTextBox1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragEnter
    5.     If (e.Data.GetDataPresent(DataFormats.Text)) Then
    6.       e.Effect = DragDropEffects.Copy
    7.     Else
    8.       e.Effect = DragDropEffects.None
    9.     End If
    10.   End Sub
    11.  
    12. Private Sub RichTextBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragDrop
    13.     Dim i As Int16
    14.     Dim s As String
    15.  
    16.     ' Get start position to drop the text.
    17.     i = CType(RichTextBox1.SelectionStart, Int16)
    18.     s = RichTextBox1.Text.Substring(i)
    19.     RichTextBox1.Text = RichTextBox1.Text.Substring(0, i)
    20.  
    21.     ' Drop the text on to the RichTextBox.
    22.     RichTextBox1.Text = RichTextBox1.Text + _
    23.        e.Data.GetData(DataFormats.Text).ToString()
    24.     RichTextBox1.Text = RichTextBox1.Text + s
    25.   End Sub

    maybe i am missing some property?

  2. #2

    Thread Starter
    New Member
    Join Date
    Jul 2003
    Posts
    11
    don't worry got it....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width