?
Solved

Drag & Drop

Posted on 1998-08-07
10
Medium Priority
?
298 Views
Last Modified: 2010-04-30
I'm having a hard time getting drag and drop to work.  I want to be able to drag from ANY program and drop into a list box.  The main problem I'm having is knowing what gets put in the OLEDragDrop, by putting in the wrong info I was able to get the wrong info added to list box but not the text I dragged.  Any ideas?
0
Comment
Question by:dokken
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 6

Expert Comment

by:anthonyc
ID: 1468245
can ya show the code you used?  
0
 

Author Comment

by:dokken
ID: 1468246
Well, the only code I was adding was:

lstbox.additem (then I tried a million different things here)

I never tried to add Drag and Drop to a program before.
In the properties for the list box I set:
OLEDragMode = Automatic
OLEDragDrop = Manual  (there were only two choices that and none)

When I drag something over the listbox I get the drop mouse pointer, but I just don't know what to put under the event.
0
 
LVL 1

Expert Comment

by:BlackAndWhite
ID: 1468247
When something is dragged over the control, the dragover event gets fired, and when something is dropped in the control, dragdrop fires.  However you application has to determine what was dropped...or atleast process only if the dropped object was of a certain type.  For example in the drop event of my listbox, if I expected only files from Windows Explorer, I would say...    

     Dim i As Integer
   
    If Data.GetFormat(vbCFFiles) = True Then
        For i = 1 To Data.Files.Count
            ListBox1.Add Data.Files.Item(i)
        Next
    End If

.You have to check what gets dropped and handle accordingly..


Feel free to ask if this doesnt answer your question..
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:dokken
ID: 1468248
It's close, I want to just add a line of text... not a file.
0
 

Author Comment

by:dokken
ID: 1468249
Adjusted points to 50
0
 
LVL 1

Expert Comment

by:BlackAndWhite
ID: 1468250
   If Data.GetFormat(vbCFFiles) = True Then
        For i = 1 To Data.Files.Count
            '######Instead on this
            'ListBox1.Add Data.Files.Item(i)
            '######Add your Line of text..
            ListBox1.Add "My Line Of Text" & i
        Next
    End If

You can also have it outside the loop if you want to add only one line for the drop operation involvind all files...and even take off the for loop all together...
0
 

Author Comment

by:dokken
ID: 1468251
BlackAndWhite,

Just tried your suggestion but it doesn't work.  The information I'm trying to add is just a normal line of text.  Like just draging a word or something from IE or any other application.  Maybe this is more trouble then it's worth. I haven't been able to find the answer to this anywhere.  I just thought it would be cool to add to the program.
0
 
LVL 1

Accepted Solution

by:
BlackAndWhite earned 200 total points
ID: 1468252
Change the type of Getformat to vbCFText
Try this out..

Private Sub ListView1_OLEDragDrop(Data As ComctlLib.DataObject,  Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
    Dim i As Integer
   
    If Data.GetFormat(vbCFText) = True Then
        MsgBox Data.GetData(vbCFText)
    End If
End Sub



0
 

Author Comment

by:dokken
ID: 1468253
That did it! I after I tested it, I changed to add it to the listbox and it worked perfectly.  I'll give you an 'A'
0
 
LVL 1

Expert Comment

by:BlackAndWhite
ID: 1468254
Thank You for the A.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month8 days, 6 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question