Tstringgrid(50)

  • 主题发起人 主题发起人 wf0156
  • 开始时间 开始时间
W

wf0156

Unregistered / Unconfirmed
GUEST, unregistred user!
delphi Tstringgrid DrawText 重影 谢谢
 
换tmsAdvStringGrid控件试一下~~
 
最好不换,不熟
 
把你的代码贴出来看看。
 
是字体重影还是背景重影?若是背景重影,在DrawText之前设置StringGrid的Brush的style为bsClear,即可消去(画完之后记得变化之前的style),若是字体重影,可能是画了多次,在每次DrawText之前,先把Rect清一下。
 
procedure TFrmmain.SGjishiDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);begin// SGjishi.Canvas.TextOut(Rect.left, Rect.Top + 8, pchar(SGjishi.Cells[ACol, ARow])); ///2009.3.26.10.00 wf DrawText(SGjishi.Canvas.Handle, pchar(SGjishi.Cells[ACol, ARow]), length(SGjishi.Cells[ACol, ARow]), Rect, DT_VCENTER or DT_WORDBREAK or DT_LEFT); /// if ACol = 0 then begin if SGjishi.Cells[6, ARow] = '货源' then with SGjishi.Canvas do Draw(Rect.left, Rect.Top, ImageH.Picture.Graphic); if SGjishi.Cells[6, ARow] = '车源' then with SGjishi.Canvas do Draw(Rect.left, Rect.Top, ImageC.Picture.Graphic); end; //rect.Top:=rect.Top+20;end;
 
for i := Frmmain.SGjishi.RowCount downto 1 do begin Frmmain.SGjishi.Rows := Frmmain.SGjishi.Rows[i - 1]; end; Frmmain.SGjishi.RowCount := Frmmain.SGjishi.RowCount + 1; for i := Frmmain.SGjishi.RowCount downto 1 do begin ll := length(Frmmain.SGjishi.Cells[1, i]) div Frmmain.SGjishi.ColWidths[2]; //得到字需要几行的行数。 case ll of 1: //1行 begin Frmmain.SGjishi.RowHeights := 30; end; 2: begin Frmmain.SGjishi.RowHeights := 60; end; 3: begin Frmmain.SGjishi.RowHeights := 90; end; 4: begin Frmmain.SGjishi.RowHeights := 120; end; 5: begin Frmmain.SGjishi.RowHeights := 150; end; end; end;
 
sgjishi.Brush.Style := bsclear; DrawText(SGjishi.Canvas.Handle, pchar(SGjishi.Cells[ACol, ARow]), length(SGjishi.Cells[ACol, ARow]), Rect, DT_VCENTER or DT_WORDBREAK or DT_LEFT); ///这样试了,不行
 
请问一下怎么清rect?谢谢
 
你在 DrawText 之前要先把背景 Brush 一下(作用就是把默认的文字输出刷掉), 就可以了
 
还不结帖?~~ 引用一下地质兄的: 莫非想回吞? ^_^
 
多人接受答案了。
 
后退
顶部