This is with the latest version of UI pack (30 Aug 2021) and Delphi 10.4
There seems to be a problem with TAdvStringGrid when "direct edit" is turned on, where simply right-clicking a cell can result in the contents of one cell being copied to another. Below is code that can be used to reduce this. The precise sequence of steps to follow is:
- Left-click any cell to select it (and automatically enter edit mode)
- Right-click the cell – the standard Windows menu with Copy, Paste, etc is displayed
(The problem occurs regardless of whether or not anything in this menu is selected) - Left-click another cell to select it (and automatically enter edit mode)
The contents of the first cell selected (and right-clicked) will be replaced with the contents of the second cell selected
type
TForm1 = class(TForm)
AdvStringGrid1: TAdvStringGrid;
procedure FormShow(Sender: TObject);
end;
var
Form1: TForm1;
implementation
procedure TForm1.FormShow(Sender: TObject);
var
r: Integer;
c: Integer;
begin
AdvStringGrid1.Options := AdvStringGrid1.Options + [goEditing];
AdvStringGrid1.MouseActions.DirectEdit := true;
for r := 1 to 5 do
for c := 1 to 5 do
begin
AdvStringGrid1.Cells[c, r] := IntToStr(c) + '-' + IntToStr(r);
end;
end;