TAdvStringGrid: No copied Object during DnD?

Hi,


I have two AdvStringGrid instances in one form and want to move rows using Drag&Drop between both. This is working already, the options to move and insert etc. complete rows seem to be fine. The problem is that I associated objects with the rows of the source grid and need those objects in the target grid as well. It seems that while all the content of the row is moved, the associated object is not.

Is that correct or am I doing something wrong?

If objects are not moved automatically, wouldn't that be a reasonable feature to add, configurable like other things regarding DnD and rows?

I guess I need to implement OnOleDragStart|Stop, to store the object associated with the row to be moved in the instance and assign it to the row in stop again?

Thanks!

Please set grid.Navigation.AllowFmtClipboard = true

Did that and got two problems: Dropping a row in the target grid AFTER the last row contained results in an exception and BEFORE the last row works, but the associated object is still NULL. Are we talking about the same associated objects? I don't mean cell properties, but the Objects-Array of the grid.


I get the exception even in a test project with an empty, pretty much default grid.

> Project RecipientSearchTests.exe raised exception class EListError with message
> 'List index out of bounds (-1)'.



It seems I was looking at the wrong rows, now I have the associated object after a drop operation. But I couldn't resolve the exception yet...

This is test code on 2 default grids:


procedure TForm1.AdvStringGrid2ClickCell(Sender: TObject; ARow, ACol: Integer);
var
  obj: tobject;
begin
  obj := advstringgrid2.Objects[acol,arow];

  if assigned(obj) then
    outputdebugstring(pchar(obj.ClassName));

end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  advstringgrid1.RandomFill(false);
  advstringgrid1.Navigation.AllowClipboardAlways := true;
  advstringgrid1.Navigation.AllowFmtClipboard := true;
  advstringgrid1.DragDropSettings.OleDropSource := true;
  advstringgrid1.DragDropSettings.OleDropTarget := true;


  advstringgrid2.Navigation.AllowClipboardAlways := true;
  advstringgrid2.Navigation.AllowFmtClipboard := true;
  advstringgrid2.DragDropSettings.OleDropSource := true;
  advstringgrid2.DragDropSettings.OleDropTarget := true;
  advstringgrid1.Objects[1,1] := button1;
end;

Dragging cell 1,1 to any cell in the 2nd grid and clicking on this cell after dragging clearly shows here that the assigned object 'TButton' was dragged and there isn't any exception here.

I think I got it: I have OleAppendRows and OleEntireRows enabled to be able to append rows and if both are enabled, I get the exception with your example code. If only one of both is enabled, I'm not able to append, the little green arrow showing the current row doesn't get past the last row. With both it does and *bang* here...

While OleAppendRows and OleEntireRows has to be enabled in the TARGET, AllowFmtClipboard of the SOURCE grid is the problem. If it is enabled, an exception is thrown else the cell is copied to the target.



Thanks for reporting. We could trace & solve this issue. The next update will address this.