You must tell grid2 somehow which cell(s) you want highlighted. There are many ways to do this, depending on what you want to do.
If you just want the last cell clicked highlighted create a couple of form variables, say fx and fy and set them in your onclick event and refresh grid2. Then use the following OnDraw event for grid 2.
procedure TFormAdobeTest.StringGrid2DrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
begin
if (ACol = fx) and (ACol =fy) then
begin
StringGrid2.Canvas.Brush.Color := clRed;
StringGrid2.Canvas.Rectangle( Rect );
end
else
begin
StringGrid2.Canvas.Brush.Color := clWhite;
StringGrid2.Canvas.Rectangle( Rect );
end;
end;
Obviously this could be extended of you want all clicked boxes recorded. Another way to do this is to instead use the objects property to tell StringGrid2 to pass this information for example by assigning StringGrid1 to the objects property (or any other object!)
an then the routine become
procedure TFormAdobeTest.StringGrid2DrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
begin
if Assigned( StringGrid2.Objects [ ACol, ARow]) then
begin
StringGrid2.Canvas.Brush.Color := clRed;
StringGrid2.Canvas.Rectangle( Rect );
end
else
begin
StringGrid2.Canvas.Brush.Color := clWhite;
StringGrid2.Canvas.Rectangle( Rect );
end;
end;
These are just a starting point of course.