Recent

Author Topic: [Solved] StringGrid Cells Colored to be "invisible"  (Read 661 times)

DeBritto

  • Jr. Member
  • **
  • Posts: 68
[Solved] StringGrid Cells Colored to be "invisible"
« on: April 02, 2019, 12:53:33 am »
Hi
I have this "StringGrid" and I need to change the color of the empty cells so it can be the same color of the component background, in order to be invisible. As if it doesn't even "exist" to the user. Is this possible?
Best regards
« Last Edit: April 02, 2019, 01:48:21 am by DeBritto »

DeBritto

  • Jr. Member
  • **
  • Posts: 68
Re: StringGrid Cells Colored to be "invisible"
« Reply #1 on: April 02, 2019, 01:25:12 am »
I found the solution on Internet
Here: https://stackoverflow.com/questions/6701462/delphi-how-can-i-change-color-of-a-cell-in-string-grid

Code: Pascal  [Select][+][-]
  1. procedure TFItemOrderer.StringGrid1DrawCell(Sender: TObject; aCol,
  2.   aRow: Integer; aRect: TRect; aState: TGridDrawState);
  3. begin
  4.   if (ACol = 3) and (ARow = 2) then
  5.     with TStringGrid(Sender) do
  6.     begin
  7.       //paint the background Green
  8.       Canvas.Brush.Color := clGreen;
  9.       Canvas.FillRect(aRect);
  10.       Canvas.TextOut(aRect.Left+2,aRect.Top+2,Cells[ACol, ARow]);
  11.     end;
  12. end;    
  13.  

 

TinyPortal © 2005-2018