stringgrid重绘时重影

秋天之落叶 2019-10-12 02:50:52
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
s: String;
R: TRect;
begin
with StringGrid1 do
begin
Canvas.FillRect(Rect);
S := Cells[ACol,ARow];
R := Rect;
DrawText(Canvas.Handle,PChar(s),Length(s),r,DT_CENTER or DT_SINGLELINE or DT_VCENTER); //文字居中
end;
end;

Canvas.FillRect(Rect)这句不起作用,光标到达单元格时,全是重影。
defaultdrawing:=false后,全部单元格冻结不能操作,也不行。
...全文
148 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
秋天之落叶 2019-10-12
  • 打赏
  • 举报
回复
看来这个赋值是关键Canvas.Brush.Color := clWhite
我加一个其他颜色的光标条看看能不能解决。
秋天之落叶 2019-10-12
  • 打赏
  • 举报
回复
引用 1 楼 早打大打打核战争 的回复:
Canvas.Brush.Style := bsSolid;
Canvas.Brush.Color := clWhite;
Canvas.FillRect(Rect);

嗯,解决了重影,但光标条中断了。
  • 打赏
  • 举报
回复
Canvas.Brush.Style := bsSolid;
Canvas.Brush.Color := clWhite;
Canvas.FillRect(Rect);

5,390

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧