FillRect不会TStringGrid在 Delphi XE2 中绘制完整的单元格。默认颜色的左侧有 3 个像素的间隙(BiDiMode设置为bdLeftToRight)。这个问题在我之前使用的 Delphi 6 中不存在。
procedure TShapeline.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
Stringgrid1.Canvas.Brush.Color:=$00FF80FF;
StringGrid1.Canvas.FillRect(Rect);
end;
我尝试更改所有属性(包括DrawingStyle)和不同的画笔样式,绘制的矩形不会填充整个单元格。