unit DbButtonComBoBox;interfaceuses
  Windows, Messages, SysUtils, Classes, Controls, Graphics, DB, DBCtrls,
  cxClasses, cxContainer, cxCustomData, cxDataStorage, cxDB, cxDBData,
  cxLookAndFeels, cxEdit, cxDBEdit, cxEditConsts, cxDropDownEdit,
  cxLookupEdit, cxDBLookupEdit, cxLookupGrid, cxLookupDBGrid,
  cxFilterControlUtils,cxButtonEdit,cxDBLookupComboBox;type
  TMyComponentEvent = procedure (Sender: TObject;AButtonIndex: Integer) of object;
  TcxDBLookupComboBoxEx = class(TcxDBLookupComboBox)
  public
    constructor Create(Awoner:TComponent);override;
  protected
    procedure MyEventTransfer(sender:TObject;AButtonIndex: Integer);virtual;
  private
    FMyEvent: TMyComponentEvent;
  published
    property MyEvent: TMyComponentEvent read FMyEvent write FMyEvent;
  end;procedure Register;implementation{ TcxDBLookupComboBoxEx }constructor TcxDBLookupComboBoxEx.Create(Awoner: TComponent);
begin
  inherited;
with TcxLookupComboBoxProperties(Properties).Buttons.Add do
  begin
    Kind := bkText;
    Caption:='查询';
  end;
    TcxLookupComboBoxProperties(Properties).OnButtonClick:=FMyEvent;
end;procedure Register;
begin
  RegisterComponents('OwenPackage', [TcxDBLookupComboBoxEx]);
end;{ AlignBtn1 }procedure TcxDBLookupComboBoxEx.MyEventTransfer(sender: TObject;AButtonIndex: Integer);
begin
  if Assigned(FMyEvent) then FMyEvent(Self,AButtonIndex);
end;end.
按钮有,事件也有,但事件不对应按钮,高手帮忙看看

解决方案 »

  1.   

    搞笑,AButtonIndex根本是一个没用的参数,根本没看见怎么传这个参数的
      

  2.   

    AButtonIndex是AButtonIndexTcxLookupComboBoxProperties(Properties).OnButtonClick的参数,事件参数不同能这样写成TcxLookupComboBoxProperties(Properties).OnButtonClick:=FMyEvent; 
      

  3.   

    执行什么都行嘛 
    procedure TForm1.cxDBLookupComboBoxEx1PropertiesChange(Sender: TObject);
    begin
      ShowMessage('');
    end;
    关键是没反应
      

  4.   

    constructor TcxDBLookupComboBoxEx.Create(Awoner: TComponent); 
    begin 
      inherited; 
      with TcxLookupComboBoxProperties(Properties).Buttons.Add do 
      begin 
        Kind := bkText; 
        Caption:='查询'; 
      end; 
      //TcxLookupComboBoxProperties(Properties).OnButtonClick:=FMyEvent; 
      Properties.OnButtonClick:= MyEventTransfer; 
    end;