|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Dragging a file from Windows into My programI 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 Pam,
In the 101 samples for VB 2003 is a sample How to create an explorer style Application. http://www.microsoft.com/downloads/details.aspx?FamilyId=08E3D5F8-033D-420B-A3B1-3074505C03F3&displaylang=en Probably is in that all you ask. I hope this helps, Cor 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: Show quoteHide quote > Pam, > > In the 101 samples for VB 2003 is a sample > How to create an explorer style Application. > > http://www.microsoft.com/downloads/details.aspx?FamilyId=08E3D5F8-033D-420B-A3B1-3074505C03F3&displaylang=en > > Probably is in that all you ask. > > I hope this helps, > > Cor 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). <pamelaflue***@libero.it> wrote in message Show quoteHide quote news:1138731281.001215.175910@g47g2000cwa.googlegroups.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 > 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: Show quoteHide quote > 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). > > <pamelaflue***@libero.it> wrote in message > news:1138731281.001215.175910@g47g2000cwa.googlegroups.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 > >
how do you execute javascript after script is regsistered?
Outlook.MaiIteml.Move: The RPC server is not available Can't View Form in Designer Visual Basic .NET 2005 Express Unhandled handled exception in Catch line Event order problem Dynamic Menus with Events ComboBox Using Winsock / TCP Client how do I enable the scrollbars in my textbox drop down inside a datagrid example? (windows forms, not asp) |
|||||||||||||||||||||||