Question[Help]Drag & Drop?

Posts 16–30 of 36 · Page 2 of 3
Next step : Converting it from a notepad into a full text processor such as Microsoft word.
;D Now THAT would be impressive.
Quote Originally Posted by NextGen1 View Post
Oh yeah you did, didn't see it, but I bet it was overlooked, and jason didn't say that, plus even though it's a properly , runtime is the best bet , and giving the code may allow them to realize it, when someone see's code a lot of time they C&P and don't read the text prior. I din't even see it because I meticulously read over your code, so I didn't see it because I myself didn't read the preceding text
My code even has allowdrop hardcoded, so
Yeah, I see it now. I skimmed through yours because you said "as kevin said" so I assumed you just c&ped his

mistakes are mistakes, however, I bet you any amount of money that was the issue....because my code works 100% , and considering both yours and kevins should work as well, that is the only solution that makes sense.
Quote Originally Posted by NextGen1 View Post
Yeah, I see it now. I skimmed through yours because you said "as kevin said" so I assumed you just c&ped his

mistakes are mistakes, however, I bet you any amount of money that was the issue....because my code works 100% , and considering both yours and kevins should work as well, that is the only solution that makes sense.
Oh so you just "assume" I'm a CPer?

loljks. but seriously, I think the state of the AllowDrop property is going to be the problem.
And I agree, so.......

:WAITS:
I tried that, and it comes up with font and alignment codes. Not just the text. HALP D:
hmmmmmm, Works fine for me every time, code exactly as you have it?
Quote Originally Posted by NextGen1 View Post
hmmmmmm, Works fine for me every time, code exactly as you have it?
Maybe it has something to do with changing textbox1 to RichTextBox1, as I am using a RTB.
Code:
 Private Sub RichTextBox1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragEnter
        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
            e.Effect = DragDropEffects.All
        End If
    End Sub
    Private Sub TextBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragDrop
        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
            Dim MyFiles() As String
            MyFiles = e.Data.GetData(DataFormats.FileDrop)
            RichTextBox1.Text = My.Computer.FileSystem.ReadAllText(MyFiles(0))
        End If
    End Sub
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        RichTextBox1.AllowDrop = True
    End Sub
So it is all working fine or are they're still errors?
PS; Google is your friend.
@ Kody, It may help to read through the thread, we all know what he want's to do.
And yes, google is your friend, however, we are here to help, this section wouldn't need to exist if we only respond in that manner.

So please refrain from using this section to increase your post count. Thanks.
Nope, works with rich text box as well, just tested it, one second though

Edit
I am however able to duplicate the issue with a .doc , is that what you are trying to do or is it a .txt


Nope, I try and drag and drop a .rtf
Issue is the dropping of a rtf lands real rtf code, which can be converted to plain tex





So we need to convert rtf to .txt now? is that the problem?


You can use RegEx, which Is what I though Jason was hanging around for then he left, the other option (more practical is)

Add this after the end if in drag drop

Code:
RichTextBox1.Rtf = RichTextBox1.Text
This should work and still preserve the format (font,size, color, etc)

So it would be

Code:
 Private Sub RichTextBox1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragEnter
        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
            e.Effect = DragDropEffects.All
        End If
    End Sub
   
 Private Sub TextBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragDrop
        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
            Dim MyFiles() As String
            MyFiles = e.Data.GetData(DataFormats.FileDrop)
            RichTextBox1.Text = My.Computer.FileSystem.ReadAllText(MyFiles(0))
        End If
RichTextBox1.Rtf = RichTextBox1.Text
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        RichTextBox1.AllowDrop = True
    End Sub
let me know


Edit: Note: You only need the one bolded line, the other (dim rtb1 as richtextbox, was a test to use a second rtb to fix the issue, but I didn't need it)

Posts 16–30 of 36 · Page 2 of 3
This thread is closed for replies.

Tags for this Thread

None

Talk with us