给你个思路,将StringGrid的DefaultDrawing属性设为False,然后在OnDrawCell事件中写:
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if StringGrid1.Cells[ACol, ARow] = '1' then
StringGrid1.Canvas.Font.Color := clBlue
else
StringGrid1.Canvas.Font.Color := clBlack;
DrawText(StringGrid1.Canvas.Handle, PChar(StringGrid1.Cells[ACol, ARow]), -1,
Rect, DT_LEFT or DT_VCENTER);
//StringGrid1.default
end;
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if StringGrid1.Cells[ACol, ARow] = '1' then
StringGrid1.Canvas.Font.Color := clBlue
else
StringGrid1.Canvas.Font.Color := clBlack;
DrawText(StringGrid1.Canvas.Handle, PChar(StringGrid1.Cells[ACol, ARow]), -1,
Rect, DT_LEFT or DT_VCENTER);
//StringGrid1.default
end;
你的方法不错,20分奉上,很轻松吧~~~~~~~~~~~以后仍请多多指教,多谢!!