AllowSmartClipboard Question

When a user utilizes the AllowSmartClipboard option and drags a field down over multiple other fields - is there a way to detect which fields were updated? I need to recalculate things based upon knowing which fields they updated. I couldn't seem to find an event that would provide this information.


Thanks,

Rhett Price

The OnCellsChanged event is triggered, returning the range of cells that was changed.

Thanks for the tip Bruno. I had tried using that, but whenever I "dragged" a value down to an adjacent cell - the OnCellChanged would throw a TRect encompassing 1) the 1st cell being dragged then 2) every single cell in the grid after that. After a lot of playing around with this, I realized that the Binder option (I have this grid bound to another grid using a GridBinder) Seemed to be causing this. Any idea why this occurs? Is there a way to tell which OnCellChanged occurs from the "binder" option vs the OnCellChanged.


Thanks,

Rhett Price

I cannot reproduce this.

Test project was created here with binder connecting 2 grids and code:


procedure TForm1.AdvSpreadGrid1CellsChanged(Sender: TObject; R: TRect);
begin
  listbox1.Items.Add(inttostr(r.Left)+':'+inttostr(r.Top)+':'+inttostr(r.Right)+':'+inttostr(r.Bottom));
end;

procedure TForm1.AdvSpreadGrid2CellsChanged(Sender: TObject; R: TRect);
begin
  listbox2.Items.Add(inttostr(r.Left)+':'+inttostr(r.Top)+':'+inttostr(r.Right)+':'+inttostr(r.Bottom));
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  advspreadgrid1.Navigation.AllowSmartClipboard := true;
  advspreadgrid2.Navigation.AllowSmartClipboard := true;

  advspreadgrid1.Navigation.AllowClipboardShortCuts := true;
  advspreadgrid2.Navigation.AllowClipboardShortCuts := true;

  AdvSpreadGrid1.SelectionRectangle := true;
  AdvSpreadGrid2.SelectionRectangle := true;

  AdvSpreadGrid1.SelectionResizer := true;
  AdvSpreadGrid2.SelectionResizer := true;

  advspreadgrid1.MouseActions.RangeSelectAndEdit := true;
  advspreadgrid2.MouseActions.RangeSelectAndEdit := true;
end;


If a problem persists, please contact us by email and include a sample source project + exact steps how to reproduce the problem.

Thanks Bruno - I was actually able to duplicate here with the sample code you provided. I will send in a sample project to demonstrate. Thanks! - Rhett

Hi Bruno,


I haven't heard anything from support so thought I would try here.

This project shows the issue:

Here are 2 screenshots - 1 showing the sample Bruno suggested and the results, the other showing the results with the 1st grid having its "Binder" disconnected.


You can see that when I drag 1 cell down, it's doing the cell that changed and then the range of all cells.
After unbinding, it works - however you will notice it seems indicate the original "dragged" cell is changed twice (even though it's really not changing at all)

The only thing I could think that is non-standard is I have compiled the TMS Adv. Spreadgrid/ESBCPC Combo package but I wouldn't think this would affect this.

Let me know if you need any more info.

Thanks,

Rhett

This is indeed caused by the TGridBinder. The reason is that when there is a TGridBinder, the change of a cell could cause a recalculation of the connected grids. When there is a recalculation, OnCellsChanged() is triggered for the entire grid. We have now refined this that when there are no recalculations within the grid where the paste happens, it will not trigger OnCellsChanged. The next update will have this improvement.

OK great thanks Bruno I will keep an eye out for it.


- Rhett