我派生了一个TGridEh的子类,里面自动创建了一个Edit对象,画在"GoodsNo"字段上,我想通过Edit对象的Change检查数据库中的记录,在ListBox(ListBox也为动态生成控件,显示在Edit下方)中过滤相应数据。
  但是,我可以把Edit的OnEnter和OnKeyDown事件绑定,但却无法绑定Edit的OnChange和ListBox的OnClick事件。
  我觉得可能是被父控件的消息捕获了,不知如何解决~~~~

解决方案 »

  1.   

    constructor TDBGridEhEdit.Create(AOwner : TComponent);
    begin
      inherited Create(AOwner);
      FOwner := AOwner;
      Parent:=TWinControl(AOwner);
      if EDT_Absord = nil then
        EDT_Absord := TEdit.Create(FOwner);
      EDT_Absord.Parent := Self;
      EDT_Absord.BorderStyle := bsNone;   
      EDT_Absord.OnChange  := EditChange;//不好使
      EDT_Absord.OnKeyDown := EditKeyDown;//好使
      EDT_Absord.OnEnter   := EditEnter;//好使
      EDT_Absord.OnExit    := EditExit;//好使  if List_Goods = nil then
        List_Goods := TListBox.Create(FOwner);
      List_Goods.Parent := Self;
      //如不加此句,操作Edit时报错  Control '' has no parent window
      List_Goods.Visible := False;
      List_Goods.Height := 112;
      List_Goods.Width := 257;
      List_Goods.OnClick := ListClick;//不好使
      List_Goods.OnKeyDown := ListKeyDown;//好使
      List_Goods.OnExit  := ListExit;//好使
      Self.OnDrawColumnCell := DrawColumnCell;
    end;EditChange和ListClick根本没有执行。
      

  2.   

    EditChange和ListClick只有Showmessage('1');没有执行~~~