T
typer
Unregistered / Unconfirmed
GUEST, unregistred user!
我写了下面的代码,用来在DBGrid下面加一行,但当Columns的长度由大于DBGrid的宽度拖到小于DBGrid的宽度时,后面仍留着一些匡格,不知怎么刷新!
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
Rct:Trect;
begin
if (Rect.right>DBGrid1.Width) then
rct.right:=DBGrid1.Left+DBGrid1.Width
else rct.right:=DBGrid1.Left+Rect.right;
Form1.Canvas.pen.color:=clred;
Form1.Canvas.RectangleDBGrid1.left+Rect.left,DBGrid1.top+DBGrid1.height, rct.right,DBGrid1.top+DBGrid1.Height+Rect.Bottom-Rect.top);
end;
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
Rct:Trect;
begin
if (Rect.right>DBGrid1.Width) then
rct.right:=DBGrid1.Left+DBGrid1.Width
else rct.right:=DBGrid1.Left+Rect.right;
Form1.Canvas.pen.color:=clred;
Form1.Canvas.RectangleDBGrid1.left+Rect.left,DBGrid1.top+DBGrid1.height, rct.right,DBGrid1.top+DBGrid1.Height+Rect.Bottom-Rect.top);
end;