Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drag & Drop within a VBA listbox?

Status
Not open for further replies.

FractalWalk

Technical User
Joined
Nov 18, 2002
Messages
141
Location
US

I have created a listbox on a VBA user from in Excel 2002. I want the user to be able to re-arrange the order of the values in the box by dragging and dropping. It seems that VB supports this but not VBA.

Is there a way to trap the mouse down/move/up events to simulate drag & drop capabilities. Any examples would be greatly appreciated.
 
Take a look at the MouseDown, MouseMove and MouseUp events of your ListBox.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
I know that I need to use the MouseDown/Move/Up events. I just don't know how to use them. Specifically, how do I know where in the list I am when I drop the item. In other words, how can the MouseUp event recognize where the cursor is in the list to place the value. Am I supposed to utilize the X,Y values and if so how?

I've looked on the web and the only thing I can find is moving values from one list to another and placing it at the end of the target list. I want to move from one part of a list to another part of the same list and that code example doesn't help.

I guess I'm looking for any examples someone might have.
 
Take a look at the StartDrag and SetText methods of the DataObject class.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top