delphi的stringgrid中字体颜色的问题
如何当单元格中为Y时,Y显示红色。forI:=1tostringgrid2.RowCount-1doifstringgrid2.Cells[3,i]='Y'thenbeg...
如何当单元格中为Y时,Y显示红色。
for I := 1 to stringgrid2.RowCount - 1 do
if stringgrid2.Cells[3,i]='Y' then
begin
end; 展开
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;
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;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询