我在多设备应用程序(在 Windows 上)中的 Delphi 10.1 中遇到问题。我有一个StringGrid
(连接到数据库),我可以更改行的背景颜色,但问题是单元格之间存在“填充”(灰色/银色)。
在onformCreate
我定义:
stringgrid1.DefaultDrawing := False;
这是我的代码:
procedure Tlist_form.StringGrid1DrawColumnCell(Sender: TObject;
const Canvas: TCanvas; const Column: TColumn; const Bounds: TRectF;
const Row: Integer; const Value: TValue; const State: TGridDrawStates);
var aRowColor: TBrush;
begin
aRowColor := Tbrush.Create(TBrushKind.Solid,TAlphaColors.Alpha);
if (stringgrid1.Cells[7,row]='1') then
aRowColor.Color := TAlphaColors.Green
else
aRowColor.Color := TAlphaColors.Red;
Canvas.FillRect(Bounds, 0, 0, [], 1, aRowColor);
Column.DefaultDrawCell(Canvas, Bounds, Row, Value, State);
aRowColor.free;
end;
在 Delphi 6 中我从来没有遇到过这个问题,而且我不知道如何修复它。谢谢你。