Several color rows in TStringGrid (Views: 2142)
Problem/Question/Abstract: Show several color in the rows of a TStringGrid. Answer: Using the OnDrawCell event... Put this code in the event OnDrawCell of the StringGrid: procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); begin with (Sender as TStringGrid) do begin if (Arow And 1)=1 then Canvas.Font.Color := clRed { En rojo / in red } else Canvas.Font.Color := clBlue; { En Azul / in Blue } Canvas.TextRect( Rect, Rect.Left + 2, Rect.Top + 2, Cells[Acol,Arow]); end; end; This example shows the even lines with a color and the odd with other... |