procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var S:String;
R:TRect;
begin
S := Trim(stringgrid1.Cells[ACol, ARow]);
R := Rect;
with stringgrid1 do
begin
DrawText(Canvas.handle, PChar(S), Length(S), R, DT_WORDBREAK);
end;
end;procedure TForm1.BitBtn1Click(Sender: TObject);
begin
stringgrid1.Cells[1,1]:='为什么总会有重影出现呢????';
end;这是我写的一个unit
可显示出来总会有重影的字
像是被画了两次一样
请问为什么?
Rect: TRect; State: TGridDrawState);
var S:String;
R:TRect;
begin
S := Trim(stringgrid1.Cells[ACol, ARow]);
R := Rect;
with stringgrid1 do
begin
DrawText(Canvas.handle, PChar(S), Length(S), R, DT_WORDBREAK);
end;
end;procedure TForm1.BitBtn1Click(Sender: TObject);
begin
stringgrid1.Cells[1,1]:='为什么总会有重影出现呢????';
end;这是我写的一个unit
可显示出来总会有重影的字
像是被画了两次一样
请问为什么?
S := Trim(stringgrid1.Cells[ACol, ARow]);
R := Rect;
with stringgrid1 do
begin
Canvas.fillRect(Rect);//先把这个CELL上的字给抹掉,然后再画一次,不知道是不是正道,反正解决了问题。希望知道正确方法的朋友提示一下
DrawText(Canvas.handle, PChar(S), Length(S), R, DT_WORDBREAK);
end;
也就是调 用了本身。。所以系统自己先画了一次,,你又画了
呵呵,不知道对不
我感觉 是这样的
property Cells[ACol, ARow: Integer]: string read GetCells write SetCells;
stringgrid1.Cells[1,1]:='为什么总会有重影出现呢????';
首先会调用SetCells函数
然后触发stringgrid1的onDrawCell事件。确实画了两遍!