I've had a request for database functionality that I've never done before, and several hours of research have led me nowhere. Here's the skinny:
My users would like to be able to drag a picture file from a digital camera onto a form and have it link to the record in the form.
Research led me to the MS ListView control as a good Drag-And-Drop activator, but I can't get an OLEDragDrop event that will work. I used the example I found somewhere - Private Sub ControlName_OLEDragDrop(Data As MSComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, Y As Single)
-
-
Dim sF As String
-
Dim J As Integer
-
-
For J = 1 To Data.Files.Count
-
sF = sF & Data.Files(J) & vbCrLf
-
Next
-
MsgBox sF
-
-
End Sub
-
and I get "The expression you entered as the event property setting produced the following error: The procedure declaration does not match description of event procedure having the same name."
If anyone has experience with this control, please give me some pointers! MSDN has been utterly useless on this subject.
Hello topher23:
I wrote some code for you that will allow you to Drag-N-Drop either Single or Multiple Files from Windows Explorer into a ListView Control named ListView1. Once dropped, all of the File's Absolute Paths will be displayed within the context of the ListView Control under a single Column Header named Absolute File Path. The code has been thoroughly tested and is fully operational, any questions feel free to ask. - Private Sub ListView1_OLEDragDrop(Data As Object, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
-
Dim varFileName As Variant
-
-
'Create an object variable for the ColumnHeader object.
-
Dim clmX As ColumnHeader
-
-
'Create a variable to add ListItem objects.
-
Dim itmX As ListItem
-
-
'Add 1 Column Header. The width of the Column Header is the width
-
'of the ListView Control.
-
Set clmX = ListView1.ColumnHeaders.Add(, , "Absolute File Path", ListView1.Width)
-
-
ListView1.BorderStyle = ccFixedSingle 'Set BorderStyle property.
-
ListView1.View = lvwReport 'Set View property to Report.
-
ListView1.OLEDropMode = ccOLEDropManual 'Initiate DROP Operation
-
-
If Data.GetFormat(ccCFFiles) Then
-
For Each varFileName In Data.Files
-
Set itmX = ListView1.ListItems.Add(, , varFileName)
-
Next
-
Else 'Data is not in the desired Format
-
Effect = ccOLEDropEffectNone
-
End If
-
End Sub
4 13685
As this is a VB6 event you should also post this in Visual Basic. You might have better luck finding someone who is familiar with it. Unfortunately, I've never used it.
I know it's stating the obvious but have you a reference to the VB6 library.
Hello topher23:
I wrote some code for you that will allow you to Drag-N-Drop either Single or Multiple Files from Windows Explorer into a ListView Control named ListView1. Once dropped, all of the File's Absolute Paths will be displayed within the context of the ListView Control under a single Column Header named Absolute File Path. The code has been thoroughly tested and is fully operational, any questions feel free to ask. - Private Sub ListView1_OLEDragDrop(Data As Object, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
-
Dim varFileName As Variant
-
-
'Create an object variable for the ColumnHeader object.
-
Dim clmX As ColumnHeader
-
-
'Create a variable to add ListItem objects.
-
Dim itmX As ListItem
-
-
'Add 1 Column Header. The width of the Column Header is the width
-
'of the ListView Control.
-
Set clmX = ListView1.ColumnHeaders.Add(, , "Absolute File Path", ListView1.Width)
-
-
ListView1.BorderStyle = ccFixedSingle 'Set BorderStyle property.
-
ListView1.View = lvwReport 'Set View property to Report.
-
ListView1.OLEDropMode = ccOLEDropManual 'Initiate DROP Operation
-
-
If Data.GetFormat(ccCFFiles) Then
-
For Each varFileName In Data.Files
-
Set itmX = ListView1.ListItems.Add(, , varFileName)
-
Next
-
Else 'Data is not in the desired Format
-
Effect = ccOLEDropEffectNone
-
End If
-
End Sub
Thanks, ADezii, that worked beautifully! It looks like the problem was that in VB6 the variable type for Data is MsComCtlLib.DataObject (or, on some of the examples I found, just DataObject) but in VBA it's just Object. When I change the Data variable back to DataObject in your code I get the same error.
With any luck, this thread will be able to help others who also had no luck searching for a proper way to use the method in Access.
Glad it worked out for you, topher23.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Welie |
last post by:
Hi all-
I am using a listview (MSComctlLib.ListViewCtrl.2)on an Access form.
Actually there are six listviews on the form. I need to do the same
thing to all six forms so I have the loop below....
|
by: Ken |
last post by:
Hi all,
Please help! I'm attempting to apply tooltips to each
individual item in VB.Net's Listview control. In VB6 it
was easy - you just did the following
(assumes "myListView" is the name of...
|
by: BobAchgill |
last post by:
I am trying to decide which of these controls to use to
implement letting my user select a full row from
MyList. The MyList has several columns which would be
nice to sort by at run time. The...
|
by: Michael.Suarez |
last post by:
Is it me, or does it seem like they put no effort into creating the
listview control in .Net.
listview.
A few gripes I have with .Net listview that aren't present in vb6:
-Inability to set...
|
by: garyusenet |
last post by:
I have had no replies to my previous post so perhaps I didn't write it
good enough.
Please excuse new thread but i wanted to break from the last thread
hopefully this thread will be better.
...
|
by: Rob |
last post by:
VS 2005
How can you tell if a value is contained in a specific column (let's say
column 1 named Status) of a ListView ?
In a list box you could go...
If ListBox1.Items.Contains(strWhatever)...
|
by: dshubhangi |
last post by:
hi
I've set richtextbox OLEDropMode Manual,catched OLEDragDrop event & in that event written below code
Richtextbox1.OLEObjects.add ,,data.files(1)
Now I'm able to catch OLEDragDrop as well as...
|
by: Mark Olbert |
last post by:
How do I get the DataPager and ListView to play nice together when I use a custom datasource?
In my webpage, I use linq to pull data from a SqlServer database and assign the resulting...
|
by: Brian Gaze |
last post by:
I have created a ListView control and have bound this to a datasource.
Within the ItemTemplate of the ListView I have added another ListViewControl
which is databound in the code behind. The idea...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
|
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...
| |