473,770 Members | 6,322 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.GetDataP resent(DataForm ats.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.Ge tData(DataForma ts.FileDrop),
String())

Neither event appears to fire though.

Any suggestions would be most welcome

Many thanks

Griff
Feb 7 '08 #1
5 4683
On Feb 7, 9:10*am, "Griff" <GriffithsJ_... @htomail.comwro te:
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.GetDataP resent(DataForm ats.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.Ge tData(DataForma ts.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.comwro te:
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 HorizontalConte ntAlignment="Le ft" Margin="146,13, 12,0"
Name="txtFile" AllowDrop="True " Height="25" VerticalAlignme nt="Top">

<TextBox.Bitmap Effect>

<OuterGlowBitma pEffect />

</TextBox.BitmapE ffect>

</TextBox>
Feb 7 '08 #5
On Feb 7, 12:05*pm, "Griff" <GriffithsJ_... @htomail.comwro te:
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 HorizontalConte ntAlignment="Le ft" Margin="146,13, 12,0"
Name="txtFile" AllowDrop="True " Height="25" VerticalAlignme nt="Top">

<TextBox.Bitmap Effect>

<OuterGlowBitma pEffect />

</TextBox.BitmapE ffect>

</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_DragEn ter(ByVal sender As Object, ByVal e As
System.Windows. Forms.DragEvent Args) Handles txtQuery.DragEn ter

Dim fi As FileInfo
Dim sFiles As String()

If e.Data.GetDataP resent(DataForm ats.FileDrop) Then
sFiles = CType(e.Data.Ge tData(DataForma ts.FileDrop),
String())
fi = New FileInfo(sFiles (0))
If fi.Extension.To Upper = ".SQL" Then
If sFiles.GetUpper Bound(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_DragDr op(ByVal sender As Object, ByVal e As
System.Windows. Forms.DragEvent Args) Handles txtQuery.DragDr op

Dim myReader As StreamReader
Dim sFiles As String()

If e.Data.GetDataP resent(DataForm ats.FileDrop) Then
sFiles = CType(e.Data.Ge tData(DataForma ts.FileDrop),
String())
myReader = New StreamReader(sF iles(0))
txtQuery.Text = myReader.ReadTo End
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
6843
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 the the span element when I select the whole text in the SPAN and drag it. However, I want to drag it without have to select the words between the span element. The default mouse action will only select the words when i move the mouse. Can...
2
6381
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 with an "overflow: auto" it seems to lose the onmouseover event for my target. Anyone come across this issue and found a resolution? Please advise. Here is a link to my code.
6
6285
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 to frame not any object. But it should happen in a drag and drop fashion. The requirement is, user will click on one object and will drag the mouse to another frame and will drop on some object the data will be passed by this and some action will...
0
2604
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 simutate it. Can anyone help? Thanks ************************** previous post: Message 1 in thread
2
4335
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 there? What about Drag/Drop; is there more than one way for the source to make data available Is it always OLE?
6
3561
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 where the user can run on firefox/mozilla, what would be a good approach. 1. Should I overwrite the javascript code drag-and-drop to make it more browser independent. If I want to go this route, can anybody provide me a
8
10127
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 to itself (i.e. drag some fake object and drop to the tool itself). I am new to .Net programming, but from my reading can I achieve this using SendMessage() or PostMessage() to force a "Drag and Drop" operation? Thanks in advance,
2
2096
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 <object> tag. Doing this has broken the drag and drop functionality from Windows Explorer into IE (it still works fine going from IE to Windows Explorer). The problem is that whenever I drag a file over IE, IE wants to implement the drop...
14
3107
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 <div id="h" style="position:absolute;left:100;top:350;"> <img src=http://javascript.internet.com/img/cards/hearts.gif name="h"> </div> but I don't see where he references these id's and names in the JS code..
0
2497
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 application (actually in C#) called from a third party piece of software via VBScript. The VB script passes an object as a parameter which my application applies changes to. My C# application dynamically creates a form, which includes controls...
0
9591
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10225
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10053
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8880
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7415
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3969
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3573
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.