Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

How Do I Drag And Drop Files Into A Rich Text Box?

I would like to drag and drop a file from Explorer or any other application, to my application, destination being a Rich Text Box.How could i do that ???

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Drag Drop Files
Hello All.

I have a "Consultation" form in my VB.NET application. It is meant to catch a history of consultation with a client regarding a project application that they made. When a client files an issue with the company they may include emails, excel documents, pdf's and even (in the future) items for systems not yet written, and so forth.

The consultation system goes like this:

A Customer/client is a member of an organisation.
The client makes the application for funding on behalf of the organisation.
If there are any issues like, for example, the application is not filled correctly or completely, or the payments for funding fell down a black hole, or if they just need to get something off their chest related to the project application, then the system should be able to record that an issue was raised.

The "Consultation" Table contains the contact ID (The contact table contains the organisation ID), and other general data. Any consultation could in theory continue for some time and have many "events" attributed to it. Each of these events may be emails containing word documents,pdf's,excel documents or whatever. Therefore a consultation can have one or many consultation events.

Here is the question (and related sub-questions): How can I store the email and any attachments for any particular event by allowing the user to drag-drop an email into the system. What type of control could I use to allow the user to drag-drop an item like this. How could I store the item in a mysql table (taking that I already have the code to connect to the database, and so forth).

I thought about storing each item added in a record in another table called consultationeventobjects which would simply reference the consultationevent item and have a field of type BLOB which would be the actual item (Email, word document ...)

My other issue is how to open the item if the user clicks on, say a email in this control.

Any help would hopefully move me closer to the goal?

I hope someone has some good ideas.

I must also add that I am proposing using a "panel" control. Not quite sure how to display the items in the panel, but I have written some dragdrop code before (Eg. Dragging ListViewItems into a richtextbox) so I do understand the dragdrop mechanism as well.


Drag && Drop (Not Files)
Ive searched the web and the forums, and everything ive found in the forums seems to be for dragging and dropping files.

Im trying to drag the text in a cell from a ListView(Report View) into a TextBox without the item dissapearing from the ListView.

I know to do this, you have to set the OLEDragMode to manual, which ive done since Automatic removes the item from the ListView.

Ive tried using alot of the code in other threads but none works, i think its this line here maybe:

If Data.GetFormat(15) Then

What are all the formats?
Do i have to set the mouse to a different icon automatically?
Do i have to set the data myself? Im thinking that line of code above is for when you drop the item, and where you drag the item from, you gotta use Data.SetData

Am i right about those things? This is the first time ive ever worked on Drag&Drop stuff.

Drag And Drop Files

I have a system which uses the file system object to manipulate files in certain wayscurrently i specifu which file to use programaticly.

VB Code:
Dim fso As Scripting.FileSystemObjectSet fso = CreateObject("Scripting.FileSystemObject")  cFile = fso.GetFile("c:1.wav")strFile = fso.GetFileName("c:1.wav")txtUpload.Text = cFile

I am looking for a way of using drag and drop, to allow users to drop explorer files into my app which bind the file system object methods to that dropped file?

not sure if this can be done and can't seem to find any tutorials.

Many Thanks if anyone can help.

Drag-drop Txt Files
I have an problem...

I have created a txt editor in vb 6.0.
I want to drag an text file to the exe icon and then the txt in the txt file appears inside the textBox(like in notepad)

Please helpe me.........

Drag And Drop Files

i have copied an example for drag and drop files into a listbox from

I did everything how it is described in the example, but it only worked the first time i tried it.
I tried it again and again and... sometimes (very seldom) it works again.

Can anybody help me?


Drag And Drop Files

I've got a question. For our project we use Microsoft Visual Basic 6.0 and Microsoft Outlook 97.
We need to implement the feature when user can drag a file from e-mail message or Windows Explorer and drop it into the Visual
Basic form. It works quite nice with Windows Explorer. Visual Basic understands that user drags and drops a file. The problem occurs
when user tries to drag and drop file from attachment of Outlook message. The program says that it's not a file but a metafile with graphic.
There is no problem when user tries to drag and drop attached file from Outlook to Microsoft Office products or Windows Explorer. So, the question
is when can we find information about how implement drag and drop feature to get file from attachment in Outlook message to our application?

Best regards,
Roman Konovalov

Drag && Drop Files Onto Textbox
Well I want to make a really quick Mp3 and Movie list and I want to have it where I can drag files from place like the desktop or windows explorer onto a textbox where the filename (RealCoolSong.mp3) is inputted into the textbox. I think this would be very useful for me. I included the textbox example below all this. Anybody know some code that would help?


Drag And Drop Files Into A Listbox
I found this thread that says how to do it for a text box...

Link to the thread about Text boxes

it had this code:

Private Sub Text1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single )
Dim i As Integer

Effect = vbDropEffectCopy
For i = 1 To Data.Files.Count
Text1 = Text1 & Data.Files(i) & ";"
Next i
Text1 = Left(Text1, Len(Text1) - 1)
End Sub

Private Sub Text1_OLEDragOver(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single, State As Integer )
Effect = vbDropEffectCopy
End Sub
but I don't quite understand how I can get it to work with a listbox and so it'll display multiple file paths on each line of the box.

(sorry if I didn't explain that right)

Drag And Drop Files And Folders?
How can I enable my app so that it support drag and drop of files and folders?

btw, I have NO IDEA of too do this...except maybe some OLE???

[edit] I found this laying around, but it is for VB .Net, can someone help me translate it to VB6?

Windows Forms Forums

grdfiles.AllowDrop = True

Private Sub Datagrid1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DataGrid1.DragDrop

e.Effect = DragDropEffects.Copy

End Sub

Private Sub Datagrid1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DataGrid1.DragDrop

If e.Data.GetDataPresent(DataFormats.FileDrop) Then

Dim MyFiles() As String = e.Data.GetData(DataFormats.FileDrop)

For i as Integer = 0 To MyFiles.Length - 1



End Sub

Being Able To Drag && Drop UniCode Files

Ok guys, I have a UniCode aware custom control, but I need to be able to read Files which may contain unicode characters from explorer when you drag & drop them.

OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)

Does the Data.Files(1) actually set this to the clipboard? If so I may be able to use API to read the clipboard which supports UNICODE.

Or any other ideas?

Pleaze Help Me Drag'n Drop Files
hi forum,
i made a new project with a shockwave flash object
i want to know if i can be able to drag external files
onto the flash object (ex. *.mp3) & not the main form
nor a list box

Drag And Drop Data Files On To MSChart
I am fairly new to VB, so excuse my ignorance if the question appears trivial.

I would like to create a quick plotting package by draging and dropping a data file onto a MSChart. The bit I'm stuck with is how to read the data from the source into an array, and how to determine the number of columns/rows. The procesing and options I can handle, it's just reading the data in.


Listview Drag&&Drop For Specific Files
I would like to know how can i enable drag and drop in a listview only for a specific type of files?

I know i can check if Right(Data.Files(i), 3) = extension (For example, in a loop), but maybe there's a better way to check the extension of the files?

Drag And Drop List Of Files To Applicaton
I am working on an application and would like to enable users to drag files from windows explorer to the application and the application should recognize the path and filenames of the files and list them say in a listbox. Thanking you in advance because I know your replies are coming right away!

Edited by - samskid5 on 8/25/2005 3:40:54 AM

Drag&&drop Files On Richtextbox Control
i want to be able to drag and drop a file onto my richtextbox, and then open the file. i can accomplish this if i change oledropmode to manual and then in the OLEDragDrop function read Data.Files(1) to get the filename, etc. but by changing to maual drop mode i can't move and drop selected text anymore, from another instance of my program or from the same richtextbox. i'm sure i could use the same function to see if the data dropped is text, but then i wouldn't know where in my file to insert the text, because all it gives you is an x and y.

so is there a way to keep the automatic mode, but have it open a file instead of embedding it?

Drag&&Drop Files (filepath && Filename) From Explorer

I have 2 questions:
The simple one is:
How to get the directory path, simply by dragging a directory from explorer into my App?
Is it possible?

And the second q is in case if I would be dragging files (not the whole dir).
Can I get the filenames of dragged files from explorer? I want to drag more files not just one.

tx, matej

How To Drag Drop Tree View Items Using Ini Files
hi all,

[give me some code relevent help]

i am using "ini" file to populate my tree view with sections of ini files and facing problem in draging an item from tree view and drop it in other section, so in this case the position of that item in tree view is changed and it is visible in as node in other section.

below is the example of tree view, if i drag "phone#" from company and drop it below the designation then it should be deleted from company section and should be added in employee section graphically.

Root node
............address #

Implementing Copy/paste Or Drag/drop For FILES
Well i wanna create an app that lets me copy a bunch of files like explorer does it, but without more then one copy at a time. So if u ask it to copy something when he's already copying, he doesn't do it, he waits that the previous transfer is finished.

It would be like norton commander that we had in dos, 2 list of files, and we can drag/drop and cut/copy/paste from one place to the other.

If anybody knows how to do that (cut/copy/paste or drag/drop) from one list to the other, I would be gratefull for the info

By the way, if this app exist already, i would be glad to download it instead of developping it hehehehe

How 2 Refresh Explorer When You Drag&&drop Files.... READ4MORE

I created a program with a "dropbox" there you drag & drop files from Explorer. The problem is that I show different forms and Explorer wount redraw itself until all files has been proceded. So the problem is that the different forms are show as a dead image after I unloaded them.

Is there anyway to force Windows to redraw the screen?

Drag And Drop From Windows Explorer To Copy Files From 1 Dir To 2n
Windows 2000
Access 97
I am working on an issue tracking DB, where I need to link (not attach due to size) screen prints of various system errors.

I have created a public folder on a network drive to store these images, under the assumption that no one will originally save them to that location.To resolve this, I need to copy the file to this location without possibility of user error in selecting the correct folder (the DB is to be used by many people spanning a great distance). I am using the "API: Drag and Drop from Explorer" code found at and have successfully implemented it, where it displays the full local/original path to the file in the listbox on the form you create to house the code.

This is a perfect (and user friendly) interface to select the file itself and even allows me to record the original path to where the file was saved, but have been unable to find a way to pass this file name/path to a FileCopy command or even the ahtCommonFileOpenSave dialog box.

Am I overlooking any better, simpler, or more efficient way of doing this-or is it even possible? Out of frustration, the code that I have been experimenting with has become rather incomprehensible so I did not post it with this message. I have searched newsgroups high and low for a solution over the last few days and in turn have said goodbye to a few more hairs on my head. Any help or examples anyone could provide would be greatly appreciated as I need to resolve this issue quickly and it would also help me better understand how Access code works.



How To Drag Drop Tree View Items Using Ini Files
hi all,

[give me some code relevent help]

i am using "ini" file to populate my tree view with sections of ini files and facing problem in draging an item from tree view and drop it in other section, so in this case the position of that item in tree view is changed and it is visible in as node in other section.

below is the example of tree view, if i drag "phone#" from company and drop it below the designation then it should be deleted from company section and should be added in employee section graphically.

Root node
............address #

Drag 'n Drop Text
How can I drag 'n drop text from a text box of one form to a text box of another form?

How To Use Text Drag N Drop
Hi, i am not the best in VB, could someone please help me with this problem:
I want to drag and drop selected text from a textbox or listbox, into a combo box. Please Help :-)


Drag/drop Files From Explorer To Any Textbox, Combo Or Listbox...
In order to fill a texbox, combo box or listbox with files dropped from explorer you need to subclass it and handle the WM_DROPFILES message. The attached module can be dropped in to any project to enable you to have drag-drop files from explorer more easily.


Private Sub Form_Load()

Call DragDropFiles.EnableDragDrop(Me.List1)

End Sub

Desperate Please HELP??? ... Drag And Drop Files To Executable Without Command Line
I have a recycle bin replacement which works great and performs a few special tricks during the deletion process. I can drag a small number of files onto the executable and can even drag whole folders onto the executable using the command Line....but it seems to report an exrror before even reaching my code when the file selection gets quite large! It displays 'Windows cannot access the specified device,path or file. You may not have the appropriate permissions to access this item' Funny thing is if I select the files in smaller groups I can delete them all with no problems??? Is there a work around without having a constant service running in the background to monitor file selection and drop events???

Drag And Drop Text Within A VSFlexgrid

I am trying to drag and drop some text within the VSFlexgrid.
Here is what I have so far, but all that happens when I try to move my text, I get a circle with a cross through it , and drop it anywhere.
Kind Regards

Private Sub Form_Load()
VSFlexGrid1.OLEDragMode = flexOLEDragManual
End Sub

Private Sub VSFlexGrid1_BeforeMouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single, Cancel As Boolean)
End Sub

Private Sub VSFlexGrid1_DragDrop(Source As Control, X As Single, Y As Single)
VSFlexGrid1.Text vbBeginDrag
End Sub

Private Sub VSFlexGrid1_OLEDragDrop(Data As VSFlex8Ctl.VSDataObject, Effect As Long, ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
VSFlexGrid1.OLEDropMode = flexOLEDropManual
End Sub

Drag And Drop Text Within A VSFlexgrid

I am using VSFlexgrid 8.0 on my form and my question is, does anyone know how to drag and drop text within the grid itself. I have found plenty of references to drag and drop controls over a form and even to another form. I donít need to drag it to another grid, I just want to be able to move the text around to other cells. Please help.

Many thanks.

Drag And Drop A File In A Text Box...
How could i drag a file and drop it in a text box and then display that files path in the text box? Can this be done?

So if i dragged a file located at C: est.wav to the textbox it would say C: est.wav


Drag/drop Text - Should Be Simple?
I want to drag the text from a textbox of one form and drop into a textbox of another form.....

I'm using GetCursorPos.....

So, the formula would be
MouseUp Event CursorPos = Text1.Text

But, I can't seem to figure the code for this.......

Maybe something like...

Call 'something'(hwnd&, Text1.Text)

Any help?

Drag And Drop In Text Box... Urgent!
I need this to finish something up....
I have a textBox where i drag a numbers too (inside the program) but i cant figure out how to make it be able to be draged into the middle of other text
Know what i mean?
here is the code im using right now...

Private Sub Line1_DragDrop(Source As Control, X As Single, Y As Single)
Line1.Text = Line1 & Chr(Source.Index + 128)
End Sub

any help would be Great

Drag Drop Text,html,dat,etc Etc
I want to be able to drag a file, prefferably txt onto a listbox.. then it will add to the listbox and then open up on a textbox =)

how can i do ?


Drag-Drop Text File To Textbox
I am making a program a lot like notepad, which you can drag and drop any type of file into the textbox, and it opens it. (like when u drag a .txt file into notepad). i want to know how to do that, but i dont want only .txt files.

BTW, the name of the textbox is txtnew.

thanks for your help!

Can Drag-n-drop Show Text As Image?
I've got some code where I allow users to drag-n-drop between listboxes.

Right now, during the drag operation, there's a small grey square attached to the mouse cursor. I'd like to show the actual item being dragged (which is the text from the list box).

Does anyone know if you can show the text of the dragged list item during dragging, instead of an image?



Resizing Text Boxes Using Drag And Drop
I am trying to design a 'report form layout' using a picture control set to the size of my users page then adding text boxes which will eventually contain users data in the form of a printed or viewed report.

I'm allowing the user to reposition the text boxes and set font properties.

Problem is that the drag-drop routines seem to only work when the mouse pointer is OUTSIDE the textbox area. For example if I want to drag a text box across the page, no problem. If I then want to reposition it only a small amount, I can't because I have to move the mouse outside the text box.

Has anyone come across any controls which will allow me to position text boxes exactly. Or even resize them using the mouse??


Listbox To Text Box Drag And Drop Not Working Properly
Hello World,

I am still a little baby in the world of .net and am starting to learn how to walk, below is my latest issue that has me stumped. What I have accomplished with the code is that I am able to drag from a listbox "LboxNewJobs" to a textbox "txtMonday" successfully, but it will only select the first item in the index "0". What I am trying to succeed in is to be able to single select any particular item the listbox and drag it over to the textbox. So my code partly works and I am probably missing something profoundly simple.

All help is greatly appreciated.


Here's my drag and drop code
Private Sub LBoxNewJobs_MouseMove(ByVal sender As Object, _
 ByVal e As System.Windows.Forms.MouseEventArgs) Handles LboxNewJobs.MouseDown
'I Think this is where I am having my problems at:
 LboxNewJobs.DoDragDrop(LboxNewJobs.GetItemText(LboxNewJobs.SelectedItem).ToString, DragDropEffects.Copy)

   End Sub

Private Sub txtMonday_DragEnter(ByVal Sender As System.Object, _
ByVal e As System.Windows.Forms.DragEventArgs) Handles TxtMonday.DragEnter

        e.Effect = DragDropEffects.All

End Sub

Private Sub txtMonday_DragDrop(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.DragEventArgs) Handles TxtMonday.DragDrop

        TxtMonday.SelectedText = e.Data.GetData(DataFormats.Text).ToString

End Sub

Drag And Drop Outlook Email Message Into Vb6 Text Box Form
I want to drag and drop outlook email message into vb6 text box form.
Is there any sample code?
Thank you.

Drag/Drop Of A PictureBox, Keeping The Image Visible During Drag

As the title says, I need to do what seems to me should be fairly simple. I have a number of pictureboxes each filled with a static image. I would like to add the ability for a user to drag the picturebox on to ANOTHER picturebox (this one holds a image currently selected by dropdown list). Upon drop, the box and associated dropdown box should be changed accordingly.

I only need a single integer to transfer with the drag/drop operation, as each image is keyed to a number.

Now, I am not all that familier with Drag Drop at all, much less with maintaining the image while being dragged... If anyone could point me to a good tutorial, I would be much appreciative.


Dave Borneman

OLE Drag && Drop (Drag From My App To Windows Explorer)
How can I set this up:
My app will display a listview in large- or small- icon format. These icons will represent files. I would like the user to be able to drag one or more of the icons from the listview and drop them into an Explorer folder (effectively, my app would be copying these files to the desired folder). I know it's probably not rocket science, but I haven't done this before. TIA for your help...

WebBrowser Drag && Drop (get Drop Filename)?
I have Form with 2 WebBrowser's ( WebBrowser1 & WebBrowser2 )

WebBrowser1 is displaying graphic images that can be dragged and dropped into WebBrowser2 but how do I find the name of the file I dragged and dropped?

I also have another related questions.

I can select multiple images in WebBrowser1 but I cannot drop them into WebBrowser2 (only one image at a time), what type of container should I use to drop multiple images into? I know it can be done because I can drag and drop the multiple images into FrontPage.

Your cryptic clues would be enormously helpful to me

Rich Text Files?
Is there a way to convert an Excel sheet into an RTF file? I was hoping that'd be one of the available file types for the Save As option, but it's not.

There's an RTF clipboard data type, but nothing for Save As. That seems weird to me, a bit. It's one of those things that you don't notice until/unless you need it.

Save Rich Text Files
I am using a common Dialog box to save RTF, is there a way I can tell if the save button has been clicked rather than just canceled.

How To Compare 2 Files In Rich Text Box?
I'm new in VB6.I have RichTextBox1 and RichTextBox2 in my form.I looking for how to compare the texts inputed in these boxes,and then to see the relult as marked words or letters in RichTextBox2 as new text file.

Load Files ( Two Or More ) In Rich Text Box....
Is It Possible To Load two or more .Rtf Files In Rich Text Box At The Same time..........
If Yes Then Pls Tell Me The Process


Opening Rich Text Files In VB

i want to do a search and replace operations on rich text files, but im not sure which functions to use.

currently , i am trying to use FileSystemObject, but not sure whether it reads one word at a time or not.

i want to know what are my options.



Rich Text Boxes && Files
I need to take apart the text in a richtextbox line by line to put into a file because i need to return line by line.

doing this:

write #1, richtextbox.text

will make a single "entry" to the file... how can i take apart the textbox line by line?

Rich Text Box Saving To And Reading From Files
Hey all, ive run into a slight problem here.
I have managed to create a text file in a certain directory using a text box. I was hoping to use this method to save and load my settings rather than fiddle with the registry as that drove me up the wall trying to get it right

Anyway I entered this as a sample code for when the user clicks save settings
Private Sub SaveSets_Click()
RichTextBox1.Text = WebBrowser1.URL
RichTextBox1.SaveFile "C:" etc ....

Problem is when the file is outputted with just saving that result, I get a garbled text file with the URL, but also with the attributes of the font too, which is what I don't need:

tf1ansiansicpg1252deff0{fonttbl{f0fnilfcharset0 MS Sans Serif;}}
viewkind4uc1pardlang2057f0fs17 RichTextBox1
par }about:blank"

So when I use this Command, it surprisingly doesn't work!
RichTextBox1.LoadFile "C:" etc...
WebBrowser1.URL = RichTextBox1.Text
IE returns a Action Cancelled message.

Any ideas how to save the contents of the file, without the attributes of the font? Thanks

Parsing Rich Text Format Files
I was wondering if anybody has ever tried to do this?

I'm trying to decide which way works the best. Either taking each rtf file and saving it in text format, then parse out the data...


Add a Microsoft Word reference to a vb project, open the file, read and parse out the data...

Any suggestions would be greatly appreciated!!!

Open-Save Rich Text Files

I need a code to open a wordpad or word file in a rich text box and also saving from rich text box to file.


Copyright © 2005-08, All rights reserved