如何当单元格中为Y时,Y显示红色。forI:=1tostringgrid2.RowCount-1doifstringgrid2.Cells[3,i]='Y'thenbeginend;... 如何当单元格中为Y时,Y显示红色。
for I := 1 to stringgrid2.RowCount - 1 do
if stringgrid2.Cells[3,i]='Y' then
begin

end; 字体颜色直接改不了,要在OnDrawCell写代码.

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
with Sender as TStringGrid do
if (cells[ACol, ARow] = 'Y') then
begin
//Canvas.Brush.Color := clBackGround;
Canvas.FillRect(Rect);
Canvas.Font.Color := clRed;
canvas.TextOut(rect.Left, rect.Top, cells[ACol, ARow]);
end;
end;