473,327 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Drag and drop problem

Using VS2008/VBasic/WPF Application

I have a text box and wish to drap a file onto it from the file system
(explorer). I've tried to mimic what worked in VS2005 (Windows forms) and I
can't get it to work....when I drag the file onto the TextBox I get the "not
allowed" mouse symbol (a circle with a line through it).

The textbox has the AllowDrop property set to TRUE

The textbox's DragEnter() event has the following code:
If e.Data.GetDataPresent(DataFormats.FileDrop, False) Then

e.Effects = DragDropEffects.All

End If
And the textbox's Drop() event [VS2005 I used the DragDrop() event] has this
code (snippet):
Dim sData() As String = CType(e.Data.GetData(DataFormats.FileDrop),
String())

Neither event appears to fire though.

Any suggestions would be most welcome

Many thanks

Griff
Feb 7 '08 #1
5 2046
On Feb 7, 9:10*am, "Griff" <GriffithsJ_...@htomail.comwrote:
Using VS2008/VBasic/WPF Application

I have a text box and wish to drap a file onto it from the file system
(explorer). *I've tried to mimic what worked in VS2005 (Windows forms) and I
can't get it to work....when I drag the file onto the TextBox I get the "not
allowed" mouse symbol (a circle with a line through it).

The textbox has the AllowDrop property set to TRUE

The textbox's DragEnter() event has the following code:
If e.Data.GetDataPresent(DataFormats.FileDrop, False) Then

* * e.Effects = DragDropEffects.All

End If

And the textbox's Drop() event [VS2005 I used the DragDrop() event] has this
code (snippet):
Dim sData() As String = CType(e.Data.GetData(DataFormats.FileDrop),
String())

Neither event appears to fire though.

Any suggestions would be most welcome

Many thanks

Griff
Did you set the AllowDrop property of the textbox and the form to
True?
Feb 7 '08 #2
Did you set the AllowDrop property of the textbox and the form to True?

Yup
Feb 7 '08 #3
On Feb 7, 11:27*am, "Griff" <GriffithsJ_...@htomail.comwrote:
Did you set the AllowDrop property of the textbox and the form to True?

Yup
What makes you think that the events do not appear to fire? Do you
have a debug.writeline in them?
Feb 7 '08 #4
>What makes you think that the events do not appear to fire? Do you
>have a debug.writeline in them?
Yes. I have break-points (also tried message boxes etc). I'm certain the
events don't fire.

XAML for the text box is as follows:
<TextBox HorizontalContentAlignment="Left" Margin="146,13,12,0"
Name="txtFile" AllowDrop="True" Height="25" VerticalAlignment="Top">

<TextBox.BitmapEffect>

<OuterGlowBitmapEffect />

</TextBox.BitmapEffect>

</TextBox>
Feb 7 '08 #5
On Feb 7, 12:05*pm, "Griff" <GriffithsJ_...@htomail.comwrote:
What makes you think that the events do not appear to fire? Do you
have a debug.writeline in them?

Yes. *I have break-points (also tried message boxes etc). *I'm certainthe
events don't fire.

XAML for the text box is as follows:
<TextBox HorizontalContentAlignment="Left" Margin="146,13,12,0"
Name="txtFile" AllowDrop="True" Height="25" VerticalAlignment="Top">

<TextBox.BitmapEffect>

<OuterGlowBitmapEffect />

</TextBox.BitmapEffect>

</TextBox>
I only replied because I just recently figured out for the first time
how Drag and Drop works in .NET. I really can'y say why the event's
don't seem to be firing. You mention that you set the AllowDrop for
the TextBox, but are you sure you enabled it for the form as well?

Here is the working code from my application's form that makies use of
DragDrop when editing a SQL Query:

Private Sub txtQuery_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles txtQuery.DragEnter

Dim fi As FileInfo
Dim sFiles As String()

If e.Data.GetDataPresent(DataFormats.FileDrop) Then
sFiles = CType(e.Data.GetData(DataFormats.FileDrop),
String())
fi = New FileInfo(sFiles(0))
If fi.Extension.ToUpper = ".SQL" Then
If sFiles.GetUpperBound(0) = 0 Then
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If
Else
e.Effect = DragDropEffects.None
End If
Else
e.Effect = DragDropEffects.None
End If

End Sub

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

Dim myReader As StreamReader
Dim sFiles As String()

If e.Data.GetDataPresent(DataFormats.FileDrop) Then
sFiles = CType(e.Data.GetData(DataFormats.FileDrop),
String())
myReader = New StreamReader(sFiles(0))
txtQuery.Text = myReader.ReadToEnd
myReader.Close()
End If

End Sub

Feb 7 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Wang, Jay | last post by:
Hello, all, I would like to enable some text between <SPAN url="http://www.testserver.com/">WORD TO BE DRAGGED </SPAN>. I put some javascript and it will extract http://www.testserver.com/ from...
2
by: matthewmacchia | last post by:
I believe this is a Firefox bug but I was hoping someone found a workaround. I have implemented drag and drop functionality, but if I try to drag an element from a div that happens to have a div...
6
by: hemant_mishal | last post by:
Hi All, I am writting a java script library which will provide inter frame drag and drop operation. The more precise will be OLE drag and drop, which means only data will be transfered from frame...
0
by: Lauren Quantrell | last post by:
I'm trying to drop a file from Windows Explorer (or desktop, etc.) onto a field in Access2K and capture the full file path. I found an posting below that says this is possible but I cannot...
2
by: SamSpade | last post by:
There seems to be two ways to put things on the clipboard ( I don't mean different formats): SetClipboardData and OleSetClipboard If I want to get data off the clipboard do I care how it was put...
6
by: jojobar | last post by:
Hello, I look at the asp.net 2.0 web parts tutorial on the asp.net web site. I tried to run it under firefox browser but it did not run. If I want to use this feature in a commercial product...
8
by: benkial | last post by:
I am writing a small GUI tool in C#, and I want to experiment some fancy trick as follows: when the user click on a "OK" button, the code will initiate a "Drag and Drop" operation in the GUI itself...
2
by: Robert Zahm | last post by:
I have created a C# user control which display certain filesystem information, and allows the user to drag an drop files into and out of the control. I then placed this user form in IE using an...
14
by: maya | last post by:
I need a drag-n-drop script.. I have found one here.. http://javascript.internet.com/page-details/drag-n-drop.html each div containing an image has an id, and each image has a name, as in ...
0
by: RHSFSS | last post by:
Hi, I have a Drag and Drop registration problem (See http://www.thescripts.com/forum/thread434707.html for similar problem post), can anyone out thereadvise on the best solution? I have a .NET 2.0 ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.