Drag and Drop With List Box | Visual Basic 6 (VB6)
[Link]
Visual Basic 6 (VB6)
Home Source Code Samples
Search
Drag and Drop W ith List Box
Drag and Drop is an amazing feature to add to your application when you are trying to create a slick and intuitive interface for your end users. It also adds a wow factor that impresses people when they first start using an application. Another great benefit of adding drag and drop functionality to your application is that it is very logical for the user. In real life if I want to move a piece of paper from one stack to another I simply pick it up, move it, and place it in the new stack. This is the exact same gesture I go through with Drag and Drop. To use this source sample create a new VB project, add a listbox control to the form and set its DragMode property to Automatic. Go to the code window and add the following code. 1. Dim ItemCount As Integer 2. Dim I As Integer 3. 4. On Error Resume Next 5. ItemCount = [Link] 6. 7. For I = 1 To ItemCount 8. [Link] [Link](I) Level:
9. Next 10. 11. If Err Then [Link] Once you have the code in place run your program (Press F5) and then you can drag things into your list box. For example open up your My Computer explorer and drag a folder from it onto your listbox. You will see it now is located in the box. You can build upon this to add great drag and drop support to your applications. Note: The source for this was found at DreamVB which is no longer online.
Similar links
Fancy Collapsing Form Exit Replace Text in a TextBox Center your form on the screen Count the number of words in a textbox Save the contents of a list box to a file Print 3D Gradiant text on a form Fill a combo box with system fonts A very basic web server Test Looping through files and putting them in a control
1 of 4
8/30/2011 9:32 AM
Drag and Drop With List Box | Visual Basic 6 (VB6)
[Link]
Understanding Check Boxes 35256 reads
how to drag an image in an
how to drag an image in an image box? reply
Fri, 05/06/2011 - 01:24 Anonymous (not verified)
code
Here is my code, it works: Private Sub Form_Load() 'a listbox control in the form and set its DragMode property to Automatic [Link] = vbAutomatic [Link] = vbAutomatic [Link] = vbAutomatic End Sub
Mon, 11/22/2010 - 02:52 Mika (not verified)
Private Sub List1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single) Dim ItemCount As Integer Dim I As Integer On Error Resume Next ItemCount = [Link] For I = 1 To ItemCount [Link] [Link](I) Next If Err Then [Link] End Sub reply
description is incomplete
you have to do the following: - set oledragmode to auto - set oledropmode to manual - put the provided code in Sub List1_OLEDragDrop(...) regards, ekrem.
Wed, 09/29/2010 - 03:01 ekrem (not verified)
2 of 4
8/30/2011 9:32 AM
Drag and Drop With List Box | Visual Basic 6 (VB6)
[Link]
reply
hey dude ! you set the
hey dude ! you set the listbox into dragmode? if not set it and double click the listbox then follow the codes reply
Fri, 08/20/2010 - 08:23 Fifth (not verified)
Hi there, I'm a real
Hi there, I'm a real beginner to this thing,
Mon, 06/14/2010 - 23:51 Anonymous (not verified)
i typed everything that is displayed above and even copied and paste it ( and yes, i deleted the numbers 1,2,3...) but it still wouldn't run it highlighted 'On Error Resume Next' saying that its an invalid outside procedure.. what does that mean?? reply
Hi there beginner, I think
Hi there beginner, I think you just pasted the code in VB6 and then run it
Sat, 11/13/2010 - 13:43 Anonymous (not verified)
but you have to put in a 'sub' like described above ---> Sub List1_OLEDragDrop(...) then try it,btw the dim's that are before 'on error resume next' are also not in a sub but vb6 understands them because you can also declare variables in the top out of a sub. Hope this will help you reply
Post new comment
Your name: Anonymous E-mail:
The content of this field is kept private and will not be shown publicly.
3 of 4
8/30/2011 9:32 AM
Drag and Drop With List Box | Visual Basic 6 (VB6)
[Link]
Homepage:
Subject:
Comment: *
Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> Lines and paragraphs break automatically.
More information about formatting options
Preview
Unless otherwise noted, all content on this site and in the source samples is Copyrighted 2011 by the owner of [Link]. All rights reserved - Contact Information
4 of 4
8/30/2011 9:32 AM