Welcome, Guest
Username: Password: Remember me
General Forum discussions that don't fit in any of the other specific forum categories, help etc.
  • Page:
  • 1

TOPIC:

StringGrid problem 1 hour 59 minutes ago #19620

  • W. Peterson
  • W. Peterson 's Avatar Topic Author
  • Away
  • Junior Member
  • Junior Member
  • Posts: 23
  • Thank you received: 0
//StringGrid1 Draw Cell
procedure TForm1.StringGrid1DrawCell(Sender: TObject; aCol, aRow: Integer; aRect: TRect; aState: TGridDrawState);
var Grid: TStringGrid;
begin
      Grid := Sender as TStringGrid; //THIS MUST BE HERE OR 'Read Address 0000004'

      if (ARow = 0) then begin
         StringGrid1.Canvas.Brush.Color := clBlue;
         StringGrid1.Font.Color := clNone;       // this must be here for next color statement to work
         StringGrid1.Font.Color := clWhite;
         StringGrid1.Canvas.FillRect(aRect);
         StringGrid1.Canvas.TextOut(aRect.TopLeft.X + 2,
                                    aRect.TopLeft.Y + 3,
                                    StringGrid1.Cells[ACol, ARow]);
      end;

      StringGrid1.Cells[0, 0] := 'XXX';
end;


Two StringGrid1.Font.Color statements must be in each 'if (ARow = n)' statement.
The color will not change from the default black without placing another color statement before the second color statement.
Now the StringGrid1.Font.Color := clWhite; will work.

Please Log in or Create an account to join the conversation.

Last edit: by W. Peterson .
  • Page:
  • 1