Delphi DBGrid中嵌套按钮

 

procedure TManageProjForm.dbgrdhProjectDrawColumnCell(Sender: TObject;

  const Rect: TRect; DataCol: Integer; Column: TColumnEh;

  State: TGridDrawState);

var

  btnName,IconName:string;

  i :integer;

  btn:TSuiButton;

  Icon:TBitmap;

begin

  if TADOQuery(TDBGridEh(Sender).DataSource.DataSet).Active = False then

  begin

    Exit;

  end;

 

  if Column.Title.Caption ='操作' then

  begin

    btnName := 'btn_'+intToStr(adoQryFindProject.RecNo);

    if self.FindComponent(btnName) = nil then

    begin

      btn := TSuiButton.Create(self);

      btn.FileTheme := FormDataModule.suiFileTheme1;

      btn.UIStyle := FromThemeFile;

      btn.Caption := '删除';

      btn.Name := btnName;

      btn.Parent:= self;

      btn.OnClick := btnMyClick ;

    end

    else

      btn := TSuiButton(self.FindComponent(btnName));

     

    btn.Left :=  TDBGridEh(Sender).Left + Rect.Left + 5;

    btn.top:=TDBGridEh(Sender).top +Rect.top +3;

    btn.Width:= Rect.Right-Rect.Left-5;

    btn.Height:= Rect.Bottom-Rect.top-3;

    btn.SetMouseLeave;

 

    //把多余的按钮清除

    i := adoQryFindProject.RecordCount+1;

    btnName := 'btn_'+intToStr(i);

    while(self.FindComponent(btnName) <> nil) do

    begin

      TSuiButton(self.FindComponent(btnName)).Free;

      i := i+1;

      btnName := 'btn_'+intToStr(i);

    end;

  end;

end;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值