Posted by delphiman on October 21, 2005
In Reply to: color a cell in stringgrid posted by Sammy
on October 16, 2005 Location of colored cell: private ColorCol, ColorRow: integer; Set colored cell column and row with Button1, and force stringgrid to repaint: procedure TForm1.Button1Click(Sender: TObject); begin ColorCol := 4; ColorRow := 3; StringGrid1.Repaint; end; Color delphi stringgrid cell in OnDrawCell event handler: procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); var S: string; begin if (ACol = ColorCol) and (ARow = ColorRow) then begin StringGrid1.Canvas.Brush.Color := clYellow; StringGrid1.Canvas.FillRect(Rect); S := StringGrid1.Cells[ACol, ARow]; StringGrid1.Canvas.TextOut(Rect.Left + 2, Rect.Top + 2, S); end; end; good luck,
|
Annoying StringGrid Focus a grid with FG/BG setable colors Annoying StringGrid Focus
|