[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

drag and drop files in richtextbox control with their actual file names

Posted on 2006-04-28
6
Medium Priority
?
292 Views
Last Modified: 2008-02-01
Hi

Can anyone suggest a code to drag and drop any file to richtextbox

Right now if i drop any file like .doc file in richtextbox it shows file like 'work document'
it doesnt say it actual file name and when i am dragging a file and i debug in dragenter event of richtextbox ..it doesnt give me file's name.

so can anybody suggest how to drop a file in richtext box and find file's actual name
and when i click save button i need the files content so that i can save whole richtextbox content with files and texts in it.

Thanks

0
Comment
Question by:jyotikasorathia
  • 2
  • 2
4 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16561502
I am in the process of reinstalling .NET 2003, so I don't have the ability to create code right now.

What format are you using to extract data from the drag/drop object?

Bob
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16562233
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16562256
I was wondering if you were using the DataFormats.FileDrop format to get the file name?

Bob
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 80 total points
ID: 16562514
(Interesting...I didn't realize that the VB.Net 2003 RTB doesn't have the DragXXX events)

To get the files name:

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

    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 RichTextBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragDrop
        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
            Dim files() As String = e.Data.GetData(DataFormats.FileDrop)
            MsgBox(files(0))
        End If
    End Sub
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question