Board index » cppbuilder » Drag&Drop between different types of VCL controls

Drag&Drop between different types of VCL controls


2004-02-26 01:46:16 AM
cppbuilder63
Hi,
Is it possible to implement drag&drop between completely different VCL
controls ? I would like to drag for example a row from a TCustomGrid and
to "drop" it to a node from a TTreeView control, how could this be
achieved ?
Thanks,
Danny
 
 

Re:Drag&Drop between different types of VCL controls

"Danny" < XXXX@XXXXX.COM >wrote in message
Quote
Is it possible to implement drag&drop between completely
different VCL controls ?
Yes.
Quote
I would like to drag for example a row from a TCustomGrid
and to "drop" it to a node from a TTreeView control, how
could this be achieved ?
Simply set the grids DragMode property to dmAutomatic and then use the
Grid's OnStartDrag event and the TreeView's OnDragDrop event.
If you want to drag a single grid row only, then you can omit the
OnStartDrag event. Just use the TreeView's OnDragDrop to see if the Source
is a TCustomGrid, and if so then query its Row property to know which row
was highlighted at the time of the dragging.
If you want to drag multiple rows, or drag additional information with each
row, then create your own TDragObject descendant class to contain the type
of information you want to drag. In the Grid's OnStartDrag event, create an
instance of that class, fill it in as needed, and assign it to the event
handler's DragObject parameter. Then, in the TreeView's OnDragDrop event,
you can test for your class and extract the information out of it as needed.
Gambit