如何设定按钮是否可用

方法1:运用TSmartEditor.OnSetActionEnabled事件
procedure TfrmPIBill.SmartEditor1SetActionEnabled(Sender: TObject);
begin
  aLoad.Enabled := IsEnabledAction(aLoad) and (BOBroker.Processor.State in [psInsert, psEdit]);
  aPIType.Enabled := IsEnabledAction(aPIType) and not (BOBroker.Processor.State in [psInsert, psEdit]);
  cmbPIType.Enabled := Processor.State in [psInsert];
  aAgrTerms.Enabled := IsEnabledAction(aAgrTerms) and (BOBroker.Processor.State in [psInsert, psEdit]);
end;

方法2:继承父类的SetActionEnabled方法
procedure TfrmSalesMonthlyBill.SetActionEnabled;
begin
  inherited;
  //
  aLoad.Enabled := IsEnabledAction(aLoad) and (BOBroker.Processor.State in [psInsert, psEdit]);
  aPIType.Enabled := IsEnabledAction(aPIType) and not (BOBroker.Processor.State in [psInsert, psEdit]);
  cmbPIType.Enabled := Processor.State in [psInsert];
  aAgrTerms.Enabled := IsEnabledAction(aAgrTerms) and (BOBroker.Processor.State in [psInsert, psEdit]);
end;
 

你可能感兴趣的:(如何设定按钮是否可用)