* * *

Author Topic: Drag on Stringgrid  (Read 852 times)

coimbras

  • New member
  • *
  • Posts: 14
Drag on Stringgrid
« on: June 18, 2018, 01:26:56 pm »
Hello.

Is possible to drag values from a "cell" to those under it? Like in Excel?
If i select a cell, drag it value also to a emty cell under the first?
I checke the properties tha says "drag" but it does not work.

Many thanks.

Handoko

  • Hero Member
  • *****
  • Posts: 2634
  • My goal: build my own game engine using Lazarus
Re: Drag on Stringgrid
« Reply #1 on: June 18, 2018, 01:39:37 pm »
I think it is possible because TStringGrid has OnStartDrag and OnDragDrop events.

If you're going to write something like Excel, try FPSpreadsheet:
http://wiki.freepascal.org/FPSpreadsheet

jamie

  • Hero Member
  • *****
  • Posts: 916
Re: Drag on Stringgrid
« Reply #2 on: June 19, 2018, 12:42:44 am »
Without code example it's hard to say..

I just tested it on windows 10-64 bit target and it works.

The drag operation is a little anemic and thus you need to help it along...

First you can set the DragMode to dmAutomatic, this will start the drag operation as you click and drag on
the cells.

 In the OnStartDrag event you can create a TDragObject, this object is one you need to create and thus
serves as a base class to a class you have created, the virtual methods it provides need to be overridden.
 
  as for dropping in other applications, I think you need to implement the IDataObject and related api code for
windows or, do the copy clipboard and paste operation..

 at the end of the drop operation the LCL should free the object you created, you don't need to..


 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus