473,397 Members | 2,033 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,397 software developers and data experts.

Dragging a file from Windows into My program

Hi guys, I have a little question (hope it's not dumb) ;-)

I have a form, containing a TreeView, say TreeView1, I want to to add a
file to the tree:

Sub AddFile(ByVal MyFile As System.IO.FileInfo)
Dim t As New TreeNode(MyFile.Name)
Me.TreeView1.Nodes.Add(t)
End Sub

and I want to have the File (File Name / FileInfo, I guess would both
be fine) from a drag drop done from Windows Explorer (or in general
from a Windows dialog).

Could you, please, show me how to attach an handler to TreeView1 in
order to get the file from the drag drop.

Thank you very much in advance.

-Pam

Jan 31 '06 #1
4 1776
Pam,

In the 101 samples for VB 2003 is a sample
How to create an explorer style Application.

http://www.microsoft.com/downloads/d...displaylang=en

Probably is in that all you ask.

I hope this helps,

Cor
Jan 31 '06 #2
Hi Cor Thank you very much for your help.

I have downloaded and taken a look at
"VB.NET How-To Create an Explorer-Style Application"

It's a very simple application which does this:

"ExplorerStyleViewer is, as the name implies, a simpler version of the
Windows Explorer application. ExplorerStyleViewer makes known more file
information than DirectoryScanner, demonstrates how to associate icons
with file types, and allows the user to run an application associated
with the file type (if an association exists) by double-clicking the
file (just like in Windows Explorer)"

doesn't do any drag drop....

Thank you anyway Cor ! . It's useful to know about those samples.

-Pam

Cor Ligthert [MVP] ha scritto:
Pam,

In the 101 samples for VB 2003 is a sample
How to create an explorer style Application.

http://www.microsoft.com/downloads/d...displaylang=en

Probably is in that all you ask.

I hope this helps,

Cor


Jan 31 '06 #3
Thanks you Cmm. I just tried it.
I can't believe! it does work and it's so simple!!

You guys are just fantastic!!

THANKS!!!

-Pam

CMM ha scritto:
Set the AllowDrop property of the control to True.

In the control's DragDrop event do something like:

If e.Data.GetDataPresent(DataFormats.FileDrop) Then
Dim sFilesAry() As String = CType(e.Data.GetData(DataFormats.FileDrop),
String())

For i As Integer = 0 To sFilesAry.Length - 1
'do something
Next i
End If

Also you can use the DragEnter/DragOver events to inspect the data and
change the mouse pointer displayed to the user (for instance, e.Effect =
DragDropEffects.Link).

<pa***********@libero.it> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Hi guys, I have a little question (hope it's not dumb) ;-)

I have a form, containing a TreeView, say TreeView1, I want to to add a
file to the tree:

Sub AddFile(ByVal MyFile As System.IO.FileInfo)
Dim t As New TreeNode(MyFile.Name)
Me.TreeView1.Nodes.Add(t)
End Sub

and I want to have the File (File Name / FileInfo, I guess would both
be fine) from a drag drop done from Windows Explorer (or in general
from a Windows dialog).

Could you, please, show me how to attach an handler to TreeView1 in
order to get the file from the drag drop.

Thank you very much in advance.

-Pam


Feb 1 '06 #4
CMM
Set the AllowDrop property of the control to True.

In the control's DragDrop event do something like:

If e.Data.GetDataPresent(DataFormats.FileDrop) Then
Dim sFilesAry() As String = CType(e.Data.GetData(DataFormats.FileDrop),
String())

For i As Integer = 0 To sFilesAry.Length - 1
'do something
Next i
End If

Also you can use the DragEnter/DragOver events to inspect the data and
change the mouse pointer displayed to the user (for instance, e.Effect =
DragDropEffects.Link).

<pa***********@libero.it> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Hi guys, I have a little question (hope it's not dumb) ;-)

I have a form, containing a TreeView, say TreeView1, I want to to add a
file to the tree:

Sub AddFile(ByVal MyFile As System.IO.FileInfo)
Dim t As New TreeNode(MyFile.Name)
Me.TreeView1.Nodes.Add(t)
End Sub

and I want to have the File (File Name / FileInfo, I guess would both
be fine) from a drag drop done from Windows Explorer (or in general
from a Windows dialog).

Could you, please, show me how to attach an handler to TreeView1 in
order to get the file from the drag drop.

Thank you very much in advance.

-Pam

Feb 1 '06 #5

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

Similar topics

3
by: Sparky | last post by:
Does anyone know if dragging the URL from Internet Explorer and dropping it into a text box in my own program is possible? erm ..and if so, how? Failing that, is there some other method I can use...
5
by: joe | last post by:
I have an image database that I'd like to populate by dragging an image off the desktop and dropping onto a form (cut/paste would work equally as well) Any suggestions? Thanks, Joe
0
by: Sin Jeong-hun | last post by:
If FlowLayoutPanel's AutoScroll is set to true, there appears a scroll bar on the right. Normally, users would expect the contents is scrolled while they are dragging the scroll bar. Well, it does,...
16
by: Geoff Jones | last post by:
Hiya Could anybody direct me to some examples of code to do the following: Display a bitmap on a form which can then be moved about i.e. dragged, using the left down button of the mouse. ...
3
by: Liz | last post by:
I need to implement dragging a borderless form by clicking/dragging on the form surface. Using the "standard" approach (setting "CanMove" flag on MouseDown, moving the form by the delta of the...
2
by: Tull Clancey | last post by:
Does anyone have, or can anyone suggest a URL for code to drag a control around a form at run time? VB.Net 2003. I have written stuff in VB6 to do this before, but a long time ago and I don't...
11
by: jon | last post by:
I'm trying to have a section where people can just start dragging files into a textbox and the full location of the file will be stored. MS-Dos has this function built into it, and it's written in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...
0
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,...

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.