I am making very simple test app, just to see how drag & drop works.
Basically I have two stringgrids, source & destination, and want to drag one cell from the source’s select row to the destination, creating a new row for it as I drop it.
In order to keep things as simple as possible, I am using drag mode = automatic, so as not to have to code manual drag mode handlers.
WIth just a few lines of code I can drag & drop, BUT only from the first row of the source. When I try to click on different row, to use that as the source, the OnClick event handler doesn’t even fire.
Short question … can I do what I want (both drag & drop and cange the source row) when using drag mode = automatic, or not?
The drop handler looks like this …
DestinationStringGrid.RowCount := DestinationStringGrid.RowCount + 1;
DestinationStringGrid.Cells[0, DestinationStringGrid.RowCount - 1] :=
SourceStringGrid.Cells[0, SourceStringGrid.Row];
so, obviously, I want to be able to change SourceStringGrid.Row when I click on SourceStringGrid
Please let me know if teh question is not clear. Thanks in advance for your help
You can use the
OnStartDragevent to determine the mouse position where the drag started: