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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

drag & drop behaviour in a listbox

Status
Not open for further replies.

LindaRichard

Programmer
Feb 23, 2001
103
CA
Hi,

I want to drag a list item from a listbox to a textbox

In my listbox I place the following code in the

mousedown event

LPARAMETERS nButton, nShift, nXCoord, nYCoord

this.Drag(1)

and in the dragdrop event of the text box

LPARAMETERS oSource, nXCoord, nYCoord

this.value=osource.list(osource.listindex)

The drag property is set to manual and I set an arrow in the drag icon property.

My problem is with the behaviour.
Let say I have a list of items aitem,bitem,citem,ditem,eitem,fitem...

I click on bitem, the drag arrow appears, I hold the mouse down
without moving and the item is selected.

Then I click the eitem in the list, the drag arrow appears I start moving then drop a
bitem in the list box. I would have liked the eitem to be dropped not the bitem.
The problem is when I start dragging the eitem it's
not immediatly selected only when the click event is fired.

I want to avoid having two steps, first click, then drag. I would like the user to be
able to select an item then drag it in one try. I also want to maintain the users
ability to simply pick an item in the list

Anyone have any suggestions on how this can be done?

Thanks
Linda
 
Do you release the mouse button on bitem before clicking on eitem? If so, then unless you are holding down CTRL or something, bitem is deselected before eitem is selected, and eitem should be dragged when you move the mouse.

If you are not releasing the mouse button how do you "click" the eitem?

A little more detail please?



Mike Krausnick
 
Linda,

Try using the OLE drag and drop methods, rather than the native VFP ones. With the native methods, you are dragging the entire listbox object. With the OLE methods, you can choose to drag just the text of the selected item.

Mike


Mike Lewis
Edinburgh, Scotland
 
Thanks for your reply,

It's working a bit better but I am still having a problem.

I set the listbox properties to:
oleDragmode=automatic
oledragpicture to a specific icon

In the textbox I set
oledropmode= enabled

and in oledragdrop event I typed
neffect=1 &&to copy

The list box is working as I want it to but not the text box. When I drag and drop over the text box, the dropped text is inserted where I drop the text. I want the text box value to be completly replaced when I drag and drop, with no extra padding.

I tried the following code in the oledragdrop event

nEffect = 0 && don't Copy
this.Value=ALLTRIM(ThisForm.List1.List(ThisForm.List1.ListIndex))

to see if I could force it to overwrite the text box value, but this somethimes leads to the value being copied twice.

Does anyone have any idea what I am doing wrong.

Thanks again for your help.

Linda
 
Linda,

What you are seeing is the normal drag-and-drop behaviour.

Have you tried putting this in the textbox's OleDragDrop:

THIS.value = ""

I haven't tried it myself, so am not sure if it would work.

Mike


Mike Lewis
Edinburgh, Scotland
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top