各位大侠:
    你们好,我想让combobox控件实现如下功能,当combobox控件获得焦点后,按下回车键后combobox控件自动弹出内容,效果跟用鼠标点击combobox控件的combo button键一样。 可当我把combobox的autodropdown属性改为true后,只有当按下字母或数字键后才能使combobox弹出内容,按下回车键combobox控件的内容只是瞬间一闪便消失,我想请教各位大侠能否让我按下回车键后使combobx控件自动弹出内容。
     急等着用这个功能,盼各位老师早日回复。
     谢谢!
                           丁丁
                                      2000.06.14

解决方案 »

  1.   


    procedure TForm1.ComboBox1KeyPress(Sender: TObject; var Key: Char);
    begin
      if key=#13 then
      begin
        SendMessage(ComboBox1.Handle, cb_ShowDropDown, 1, 0) ;
        key:=#0;
      end;
    end;
      

  2.   

    SendMessage(ComboBox1.Handle, cb_ShowDropDown, 1, 0) ;
      

  3.   

    procedure TForm1.ComboBox1KeyPress(Sender: TObject; var Key: Char);
    begin
    if not combobox1.DroppedDown then
    begin
    if key=#13 then
    begin
    sendmessage(combobox1.handle,cb_showdropdown,1,0);
    key:=#0;
    end;
    end;
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
    form1.KeyPreview:=true;
    end;
      

  4.   

    SendMessage(ComboBox1.Handle, cb_ShowDropDown, 1, 0) ;