سورس کد زیر به شما کمک می کند که با استفاده از رویدادهای انتخاب یک سلول یا در زمان ایجاد تصویر سلول تغییرات مورد نظر شما در زمینه رنگ سلولها اعمال شود.
type
TGridCracker = Class( TStringgrid );
// required to access protected method Invalidaterow
procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin
With TGridCracker( Sender As TStringgrid ) Do Begin
InvalidateRow( Row );
InvalidateRow( aRow );
End;
end;
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
grid: TStringgrid;
begin
If gdFixed In State Then Exit;
grid := Sender As TStringgrid;
If grid.Row = aRow Then Begin
With Grid.Canvas.Brush Do Begin
Color := $C0FFFF;
Style := bsSolid;
End;
grid.Canvas.FillRect( Rect );
grid.Canvas.Font.Color := clBlack;
grid.Canvas.TextRect( Rect, Rect.Left+2, Rect.Top+2, grid.Cells[acol, arow]);
Grid.Canvas.Brush := grid.Brush;
End;