Drag Item From Listbox To Listbox
I was wondering how to drag one item from one listbox to another listbox on the same form... By using drag and drop, not by using any button.. I choose an item by pressing and holding the button and then drag it to the other listbox..
Also,How do I drag a file from outside my app and into the listbox? How to use the drag and drop (onto apps listbox) function?
Please provide a simple example(form) if you can PS: Do it as simple as possible!! No need for extra's!!
I need more help, The examples below didnt work correctly!
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Listbox--drag An Item
hi
is it possible to drag an individual item in a list box to another index(like the playlist of winamp)? how?
Drag Listview Item To Listbox
Hi how can i allow the user to drag a item from a listview to a
listbox and in the listbox a subitem is shown as items text
Drag Item From ListBox (or Similar) In .NET?
Hi,
Does anybody have an example of dragging items from a ListBox, ListView or treeview (or similar) in .NET?
I'm assuming I've got to monitor a mousedown event and then follow XY coordinates etc ... I just want to be able to drag items onto another control ... I've browsed the forums and can't seem to find an obvious example.
Any help ideas would be most appreciated.
Tim
ListBox Item Drag & Drop And Line Select
Hi
Below is the code (obtained from this forum but I cant remember from who) that I use to move lines in a listbox up or down by dragging and dropping them.
Code:
Option Explicit
Dim sCurItem As String
Dim iLastIndex As Integer
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function LBItemFromPt Lib "comctl32" _
(ByVal hwnd As Long, _
ByVal ptx As Long, _
ByVal pty As Long, _
ByVal bAutoScroll As Long) As Long
Private Declare Function ClientToScreen Lib "user32" _
(ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Sub Form_Load()
With List1
.AddItem "Item1"
.AddItem "Item2"
.AddItem "Item3"
.AddItem "Item4"
.AddItem "Item5"
End With
End Sub
Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
GoTo RBjump
Else
sCurItem = List1.List(List1.ListIndex)
iLastIndex = List1.ListIndex
End If
RBjump:
End Sub
Private Sub List1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim iCurIndex As Long
Dim pt As POINTAPI
If Button = vbRightButton Then
GoTo RBjump
Else
pt.X = X Screen.TwipsPerPixelX
pt.Y = Y Screen.TwipsPerPixelY
Call ClientToScreen(List1.hwnd, pt)
iCurIndex = LBItemFromPt(List1.hwnd, pt.X, pt.Y, False)
If iCurIndex > -1 Then
List1.RemoveItem iLastIndex
List1.AddItem sCurItem, iCurIndex
End If
End If
RBjump:
End Sub
The code works great for moving lines about but I also need to be able to highlight a line just by clicking on a line, the above code wont let me click and highlight a line, cant work out why.
Any ideas.
Thanks.
Drag And Drop An Item From Outlook Into Vb Listbox Or Textbox
Hi,
URGENT!!!!
Can someone help in how to drag and drop an item from outlook like email into vb listbox or textbox using vb programming with keeping all item's or email's properties in vb so I can access all the item's or email's properties fom vb. Can you give me a hint, code, or website to read. Any help is appreciated. Thanks in advance.
Drag Listbox Entry To Another Listbox; Selected Text Drags With Mouse Cursor
Hello everybody; new member! I am trying to figure out (in VB6) how to drag a listbox item and drop it into another listbox. That's the easy part and already have basic drag and drop mechanics down pat. What's stumping me is this... I wish to have the text contained in the original listbox entry follow the mouse cursor as I am dragging to the destination textbox. This would, in effect, be a custom drag icon. I have experimented with some API direct printing but not much success (especially when mouse cursor goes over container controls; text just slides under them!). I appreciate any help anyone can give in this area. Thanks! GumbyTheCat
Populate A Listbox Based On A Selected Item In Another Listbox
Ok...I am stumped.
I have a single form that has 3 list boxes. I have 4 public strings containing various values. Based on the selection from lstBox1, I need to populate the ListBox2 and ListBox3 list from values in the public strings. Clear as mud?? That is what I thought!
Example string variable
strLuxury = """Hand Wash"" ""Hand Wax"" ""Check Engine Fluids"" ""Detail Engine Compartment"" ""Detail Under Carriage"" ""Fragrance"" ""Shampoo Carpets"" ""Shampoo Upholstery"" ""Scotchgard"""
ListBox1 contains the following:
Standard
Deluxe
Executive
Luxury
ListBox2 is empty, but is contained in a frame indicating Exterior Options
ListBox3 is empty, but is contained in a frame indicating Interior Options
If Luxury is selected in ListBox1, then ListBox2 should contain
Hand Wash
Hand Wax
Check Engine Fluids
Detail Engine Compartment
Detain Under Carriage
And ListBox3 should contain
Fragrance
Shampoo Carpets
Shampoo Upholstery
Scotchgard
If Fragrance is present in ListBox3, a seperate dropdown box should appear allowing selection of the appropriate scent.
Yes, this is a homework assingment.
Thank you in advance for your help!
Mark
Listbox: How To Know Last Added Item's Index, When The Listbox Is Sorted?
When sorted property of a listbox is set to True, each new item added won't be at the end of the list, it will be automatically placed in the correct index, according to text order, is there a way to know which is the index of that item (last item added)? Looping to find it would be horrendous, I just need the index to mark that item selected.
.: Please Help: Copy Selected Item(s) From A ListBox To The Other ListBox..
Hi everyone!
I'm having problem with copying file to another Listbox, please help..
So, in this case, I have two ListBoxes where the 1st ListBox holds several items..
I need to copy the selected item to the other listbox 'without' a repetition, I mean.. the same item won't copied anymore..
When the user tries to copy the item which have already been in the ListBox2, then a messagebox will pop up to warn the user of the existing item.... So, how should I do that??
Thanks a lot
Drag From ListBox And Drop Into Another ListBox
Am having a complete mental block here on drag-and-drop.
Trying to copy selected items from a ListBox that has it's .MultiSelect property set to 2-Extended into another ListBox.
When more than one item is selected, I can only get the last item to drop into the second ListBox.
Any help at all appreciated.
Drag From ListBox And Drop Into Another ListBox
Am having a complete mental block here on drag-and-drop.
Trying to copy selected items from a ListBox that has it's .MultiSelect property set to 2-Extended into another ListBox.
When more than one item is selected, I can only get the last item to drop into the second ListBox.
Any help at all appreciated.
Drag And Drop From Listbox To Listbox? Help Please!
hi guys. joined 'cause i'm in a bit of a pickle.
i have a listbox that loads an array, let's say it loads folders, so that it has "Folder 1", "Folder 2", "Folder 3" and so on. now when you click on one of those folders, on another listbox, the program loads the information, which would be names of people. so if you click on "Folder 2" and the second listbox shows "Mary", "John", "Edward", etc.
i'm trying to find a way to make it so that I can click on "Edward" and drag him across to the first listbox and drop his name to another folder, thereby moving his information from folder to folder without the user having to retype everything from scratch.
now, I can get the coding done for the saving and stuff no problem, i'm just having a hard time with the drag and drop.
is there a way so that you can literally drag the "Edwards" field (meaning as you drag it it comes out of the listbox)?
that is not crucial though, i already have that part working by using a drag icon that simulates the effect, and i could ultimately just use that. however, what is becoming more and more challenging and in turn is making the code so far uglier and uglier, is determining which of the fields of the folder list box it would drop the file into...how does it know which item it is over as you drop the drag?!
in other words, how do i determine which of the items of the listbox the dragged item is being "dropped" into?
thanks a lot for the help and I hope that wasn't as confusing as it sounds to me...i'm tired!
Drag From ListBox And Drop Into Another ListBox
Am having a complete mental block here on drag-and-drop.
Trying to copy selected items from a ListBox that has it's .MultiSelect property set to 2-Extended into another ListBox.
When more than one item is selected, I can only get the last item to drop into the second ListBox.
Any help at all appreciated.
Adding An Item From One Listbox To Another Listbox
I have several forms, one with a listbox that displays the selected records of a field from a database. I select(click) one of those records and want to have another particular field from that record display in another listbox on another form. So far it works with this code, but pulls all the records from the first listbox.
To be more specific, the database has populations and zip codes, etc. The field for population is called pop2001 and the zip codes is Zip. The listbox with the selected records displays zipcodes and I want to select one of those zipcodes and have it's population display in the other forms listbox, but it displays all of them. Can anybody help?
Code:
Private Sub Form_Load()
PopRecSet.MoveFirst
Do Until PopRecSet.EOF
frmpopfinal.lstpopfinal.AddItem PopRecSet![pop2001]
PopRecSet.MoveNext
Loop
End Sub
Listbox Name Showing Up As First Item In Listbox?
For some reason the listbox I've just added to my form shows the name of the listbox in itself at design time. At run-time, the name of the listbox shows up as the first item in the list.
I've tried looking for a CAPTION or TEXT property but neither seem to be present. Any ideas as to how to fix this?
How To Search Listbox For Item If Item Not Found Add Item?
Hi, lol man I cant find nothing today when I search the forum.
This my latest problem, How do I search a listbox for an item lets say "Game Over" And if the item is found the program does nothing, but if the item is not found it will add "Game Over"
Thanks Again
Removing An Item From A ListBox By Clicking The Item
Hi, How do you remove an item from a ListBox by simply clicking the item u want to be removed?
This is the code i tried but it doesnt work:
Private Sub list1_Click()
Dim n As Long
Dim ncount As Long
ncount = List1.ListCount - 0
For n = 0 To ncount
List1.RemoveItem (n)
Next
End Sub
Any ideas?
-Flaw
Drag ListBox!!!
1. How to set the icon in the listbox properties when you want to drag the items from listbox?
2. What is the code to drag the items from listbox to textbox?
3. For example, I have text1 and text2, the user can only drag the items from the listbox to text1 only. Text2 will not accept it. How to do that?
ListBox & OLE Drag
I have a ListBox control that I want to be able to Drag out of my applicaton. I have all the code inside an OLEDrag_Start sub to handle transfering all the necessary data over to the DATA object that moves the info between apps. The problem is this, I can't figure out how to turn on the OLEDrag property on my form. It's not there. I read somewhere that's all I'd need to do, but nowhere do I see OLEDrag. I have OLEDrop in the properties, just no drag. Is there something I need to include into the project for me to be able to make this work???
Thanks...
Thomas
Drag Into ListBox
I need to drag text from one listbox to another, but i want the text to be added were i leave it, and not at the end of the listbox. I managed to do it by divding the Y position by 210 (the hight of one item):
Private Sub lstTo_DragDrop(Source As Control, X As Single, Y As Single)
Dim Pos As Single
Pos = CInt(Y / 210)
lstTo.AddItem CStr(X), IIf(Pos < lstTo.ListCount, Pos, lstTo.ListCount)
End Sub
it works fine, but when i add many items, there's a problem with the scrollbar, because it adds the item as if the scrollbar is in the top.
Drag And Drop From Listbox
I have some listboxes on a form and I want to drag values between them. What is the best way to drag from one listbox and drop into one of the others. I'm playing with Mousedown and Mouseup, but I'm not sure that is the solution. How do you know which listbox you are dragging to?
Thanks,
--bnpatten
Richmond,VA
Drag And Drop With Listbox
i have searched the forums but there seems to be a few different ways of simply dragging an item out of list1 and putting it in list2, as any body got any sample code that is the usual way of doing this
thank you.
casey.
Help (drag From Listbox To Listview)
I need to drag an item from mylistbox into listview
what makes it hard for me is i need it to drop whatever text im dragging onto the cell or whatever the mouse is over when it drops
Thanks
Listbox Drag And Drop
Hi !
I want to drag and drop an item fom a list box.
I'm able to drag this item to a text box.
But I when I do so it seems like all the listbox is moving. What can I do if I want to see like i'm moving only one item from this list box ?
Drag N' Drop From Listbox?
is it possible to drag and drop from one listbox to another, with the original one having been populated from my database? if so how would i go about this? thanks!
Drag And Drop From One Listbox To Another
I have two listboxes labeld From and To.
I need to move items from the From box to the To box.
I have four buttons:
cmdTo (moves all selected items from the From box to the To box)
cmdToAll (moves ALL items from the From box to the To box)
cmdBack (moves all selected items from the To box back to the From box)
cmdBackAll (moves ALL items from the To box back to the From box)
All works well and life is good.
Now, however, I'm being asked to add drag and drop functionality. My users want to be able to select items in the From box and Drag them over to the To box and Drop them in.
I don't even use the Drag and Drop functionality built into Windows and I've never built such functionality before.
Can anyone at least get me started?
Drag'n Drop Listbox?
Can anyone tell me if it's possible to drag and drop from a listbox, if it is, can you tell me where to go to find out how to do it?
Listbox Drag And Drop.
Until Arc has finished his listboxx OCX I am stuck with the microsoft offering. SO my problem is this, is there any way to implement re-ordering listbox items by dragging and dropping?
Everso
Listbox Drag & Drop
I am trying to create a form with multiple listboxes from which I can drag & drop from one list to any other list.
I have looked at CTLIST.OCX by DBI Technologies (www.dbi-tech.com/product_info/ctocx.htm)
but it seems this control will only allow drag & drop between 2 list only.
Can someone please help?
Listbox Drag & Drop
i am draging and droping file from desktop and list1 contaning file name and list2 contaning it's location but location says "c:windowsdesktop" but i like to have it's Targetlocation (when you right click on icon from desktop and goto "Shortcut" tab and there will be "Target" that's i am talking about) how do i get that targetlocation. I realy need help for this please help me.
Listbox Drag And Drop
i have 2 listbox how could i make program that when i drag and drop item from desktop list1 get the file name and list2 get complet location (ex:"c:Program filesInternet ExplorerIexplore.exe"). Does any one know how to do this please help me.
Thank you
ListBox Drag Items
Hi All,
I need some code to drag items in a list box either up or down along with
not just the text but with the itemdata too.
Can anyone hook me up?
TIA John
ListBox Drag&drop
I have two list boxs that i can drag from one to anther. The point is that the item is inserted in the begining of the target list. I want that the item will be inserted where the user put the cursor on (in the x,y position) How can i do it?
Here is the routine:
Private Sub List1_DragDrop(Source As Control, X As Single, Y As Single)
On Local Error Resume Next
If Source Is List1 Or Source.List(Source.ListIndex) = "" Then Exit Sub
List1.AddItem Source.List(Source.ListIndex) 'Adds the item to the target
Source.RemoveItem Source.ListIndex 'Removes the item from the source
End Sub
Drag And Drop From Listview Onto Listbox
I need to be able to perform a drag'n'drop from a listview in report-view mode onto a listbox.
I can get the first item (I want to multiple select too) that is dropped, however I cannot do the following:
1) I want multiple, performing a For Each vfn In Data.GetData(1) doesn't work, I get can the first item by msgbox data.getdata(1)
2) The destination listbox, how can I tell what item in the listbox that the dragged objects have landed on.
Cheers!
Carl.
ListBox Drag And Drop Event.
I posted a message about displaying html code in color in a rich text box. this is the same app I'm working in.
does anyone have any advise on how I can drag something listed in a list box and drop it in an rtf? My rtf will contain alot of text.
OR
would it be easier to select an area in the rtfbox, select an item from the list and then "on_click" with a commandbutton insert the list box text into the selected area of the rtfbox?
Any advise would be helpfull.
Drag And Drop Files Into A Listbox
I found this thread that says how to do it for a text box...
Link to the thread about Text boxes
it had this code:
Code:
Private Sub Text1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single )
Dim i As Integer
Effect = vbDropEffectCopy
For i = 1 To Data.Files.Count
Text1 = Text1 & Data.Files(i) & ";"
Next i
Text1 = Left(Text1, Len(Text1) - 1)
End Sub
Private Sub Text1_OLEDragOver(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single, State As Integer )
Effect = vbDropEffectCopy
End Sub
but I don't quite understand how I can get it to work with a listbox and so it'll display multiple file paths on each line of the box.
(sorry if I didn't explain that right)
Drag Drop From Listbox To Picture
OK i have a listbox and I want to be able to select an item and when i drag it onto the form I want it to become an image in an imagebox. Then when i take my finger of the mouse if it isn't within certain (X,Y) co-ords I want it to disappear otherwise just move it to certain (X,Y) co-ordinates.
Drag & Drop Within A Listbox Or Listview?
Let's say you have a listbox containing 50 items (rows) that is populated from a database table. That listbox is sorted 1 through 50 based on a field called "ORDER".
If I want to allow the user of my VB application to change the order of the records (and the order field accordingly) using drag and drop, is that possible? What I'm thinking is that they can click on, say, item 32 in the list, and drag it up or down the list to the spot they are looking for and then my program will reorder everything.
Basically, my software has a combobox that is populated and ordered using this table. On certain occaisions the user has to change this order (for data entry purposes), so they need a fast way to go about this. The way the previous programmer made it, once they order one thing differently, they have to go all the way through the list again and reorder everything else. Any tips on how to make this smooth and relativley effortless for the end user would be appreciated.
Thanks again everyone
Listbox Drag And Drop Problem
G'day,
I have 2 listboxes and want to drag/drop between them. I can do it from one to the other, but not the other way around.
I have zipped the files and attached.
What have I done wrong?
Drag Drop Problem In Listbox
Hi all
I've a prob when using the drag drop event in a listbox
I'm moving an item from one listbox to another like this
Code:
Private Sub lstReportGroups_DragDrop(Source As Control, X As Single, Y As Single)
Dim iIndex As Integer
Dim intListCount As Integer
If TypeOf Source Is ListBox Then
intListCount = Source.ListCount - 1
For iIndex = 0 To intListCount
If Source.Selected(iIndex) Then
lstReportGroups.AddItem Source.List(iIndex)
lstAvailableGroups.RemoveItem (iIndex)
Exit For
End If
Next
End If
My problem is when I select an item in one of the listboxes and drop it in the same listbox it appears again in that listbox.
How can I do if I want it to be impossible to drop the item in the 'source' listbox??
/C
Listbox Drag Drop Problem
Hello
I have a list box that the user can drag items up and down in. This works well enough except that you have to click and release on an an item and highlite it first before you can drag it. That part I can live with.
The thing that I would really like to change though is that when you drag an item you can't tell very well where you're dropping it. You get a drag icon and the pointer changes to let you know that your dragging. But it's hard to tell where it's actually going to get dropped when you release. So, What I'm looking for is for a way to have either the rows highlited as the mouse goes over them or a line that shows exactly where the cursor is pointing.
Any ideas?
Thanks
David
Rearrange A Listbox With Drag And Drop
I've been searching for a simple method to rearrage the order of items in a listbox allowing the person to drag rows up and down in the list. It does not seem to be as straight forward as I first assumed. Does anyone have any sample code to do this. the only sample code I found was dragging and dropping between different listboxes, not rearranging within the same one. Do I need to use the OLEDragStart, OLEDragDrop events? or can I simply use MouseDown, Mousemove, MouseUp events. Thanks
A sample would be much appreciated.
Marc
Urgent!! Listbox Drag And Drop
I'm trying to set up the drap and drop option between 2 listboxes and it will not work. When you click on it the icon changes and it looks like it is going to drag, but it will not drop anywhere. The main purpose of this is to be able to drag the files instead of having to select the text and then click add.
|