473,748 Members | 6,037 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 2096
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
6842
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
4332
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
3560
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
10125
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
2095
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
3104
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
8830
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
9544
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
9372
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...
1
9324
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9247
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6796
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...
0
4606
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.