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

easy way to dragdrop 2

Status
Not open for further replies.

morlassino

IS-IT--Management
Jul 1, 2004
33
0
0
US
is there an easy way to drag drop from within a grid box
like grab top record place in between another etc etc..

MARIO P ORLASSINO
ASSISTANT MANAGER IT
"THE HOSE HEAD"
 
The simple answer is "No!".

A lot depends on what the order of the file is in the browse, whether you want to change the actual order of the records of just change the current key so it's logically "between" two other records, and of course how the key is constructed.

Rick
 
Mario,

In general, you can't drag from inside a container and drop outside that container. A grid column is a container. Since a column only contains one real cell, there would be nowhwere to drop the item, even if you could drag it.

In other words, the answer to your question is No. However, you might (with some difficulty) be able to simulate a drag-drop using some other method, but it would be very tricky.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Morlassino,

Yes, you can drag and drop within a grid. You can use OLE drag and drop.

I will look for some code for you. Give me a few days - I'm on vacation and away from my primary workstation.

Malcolm
 
thanks to everyone..
Malcolm no rush thank you very much.


MARIO P ORLASSINO
ASSISTANT MANAGER IT
"THE HOSE HEAD"
 
MARIO ("THE HOSE HEAD"<g>),

Here is code from a prototype I built to demonstrate to a customer how drag and drop could be used within a grid.

...

Step 1: I set my grid's OLEDropMode to 1 (Enabled).

...

Step 2: Here's a snippet from my grid's OLEDragDrop method:

* portions of this code are from an example posted on UT by Cetin

LPARAMETERS oDataObject, nEffect, nButton, nShift, nXCoord, nYCoord

ThisForm.LockScreen = .T.

With This
nXCoord_In = Mcol(Wontop(),3)
nYCoord_In = Mrow(Wontop(),3)
Store 0 To nWhere_Out , nRelRow_Out , nRelCol_Out , nView_Out
If .GridHitTest(nXCoord_In, nYCoord_In, @nWhere_Out, @nRelRow_Out, @nRelCol_Out) And nWhere_Out = 3
.ActivateCell(nRelRow_Out, nRelCol_Out)
local lcRecord
lcRecord = "Dropped on record = " + alltrim( ALIST.cFullTitle )
else
lcRecord = "Ignoring drop"
Endif
Endwith

* NOTE: We activate dropped record vs. returning to original record.

ThisForm.LockScreen = .F.

* messagebox( "Dropped on record = " + lcRecord )
set message to lcRecord

...

Step 3: Here's a snippet from my grid's OLEDragStart() method:

LPARAMETERS oDataObject, nEffect

local lcData
lcData = alltrim( ALIST.cFullTitle )
oDataObject.SetData( lcData, 1 )
nEffect = 1 + 2 && copy + move

set message to "Start Drag"

...

You will have to modify these snippets to match your grid table. My examples just report the drag drop attempt - they don't actually reposition records.

One hassle you will have is when you try to drag a record to a new position within a large grid and the destination record is not visible within the grid's window. VFP's grid will NOT auto-scroll when you move to the top or bottom edges of the grid.

One way you might provide an auto-scroll capability would be to place shape controls at the top and bottom of a grid and have these shape control's trigger grid scroll's in their OLEdragover events (making sure that the source of drag over is the grid control and not another control).

Hope this helps!

Malcolm
 
Mario,
While you've seen you can D&D in a grid, the basic question of how to get the data in the grid to be reordered still comes down to how the data is ordered and the indexes involved.

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top