5,392
社区成员
发帖
与我相关
我的任务
分享
if ACol<> 5 then exit;//在第6列加按钮
try
self.FindComponent('but'+inttostr(acol)+'_'+inttostr(arow)).Free;
except
end;
btn:=TButton.Create(Self);
btn.Caption:='查看';
btn.Left:=Self.StringGrid1.Left+Rect.Left+5;
btn.top:=self.StringGrid1.Top+Rect.top +3;
btn.Width:=Rect.Right-Rect.Left;
btn.Height:=Rect.Bottom-Rect.top ;
btn.Name:='but'+inttostr(acol)+'_'+inttostr(arow);
btn.Parent:=self;
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
btn:tbutton;
begin
if datacol<> 5 then exit;//在第6列加按钮
btn:=TButton.Create(nil);
btn.Caption:='查看';
btn.Left:=TDBGrid(Sender).Left+Rect.Left+5;
btn.top:=TDBGrid(Sender).top +Rect.top +3;
btn.Width:=Rect.Right-Rect.Left+3;
btn.Height:=Rect.Bottom-Rect.top +3;
btn.Parent:=self;
end;