想实现功能数据比如是2个  南方机械制造公司  南通责任有限公司
在combobox中输入“南”的时候自动下拉框自动下拉  把包含“南”关键字的数据都找到填充
下面是我自己的代码  发现下拉框能找到2个数据 但是默认选中排列第一个的数据 并且下拉框中数据不能用光标单击选择  只能用键盘确定键选中第一个数据   为了自动下拉的实现我吧autodropdown 属性设置true   
请高手帮我改改 谢谢了
if(combobox3.text<>'') then begin
  with ADOQuery2 do
  begin
    close;
    SQL.Clear;
    SQL.Add('Select * FROM tb_company where CompanyName like :p and companytype like :p1');
    Parameters.ParamByName('p').Value:='%'+trim(combobox3.text)+'%';
    Parameters.ParamByName('p1').Value:='顾客';
    open;
  end;
  combobox3.items.text:='';
  ComboBox3.SelStart:=   Length(ComboBox3.Text);
 while not adoquery2.Eof do
  begin    ComboBox3.Items.Add(adoquery2.Fieldbyname('CompanyName').AsString);
    adoquery2.Next;
  end;
  end;

解决方案 »

  1.   

    得自己开发控件,或是用ButtonEdit+LookUpCombobox结合做啊。
      

  2.   

    自己在Onchange事件中,加入搜索代码即可。
      

  3.   

    这种下拉的实现多了去了!用两个控件结合使用,应该会更好实现。我用Edit和ListBox实现过。
    在Eidt的Change事件中,如下代码
    procedure TFrm_EditInfo.Ed_CarCodeChange(Sender: TObject);
    var
      CarCode: string;
    begin
      if Trim(Ed_CarCode.Text) <> '' then
      begin
        //取查询的条件
        CarCode := Trim(Ed_CarCode.Text);
        //这是一个公用函数,用来将查询的数据显示到ListBox中。
        DM.BindListBox(Lst_CarInfo, CarCode);
        //如果ListBox中有数据,则显示ListBox,否则就隐藏
        if Lst_CarInfo.Items.Count > 0 then
        begin
          Lst_CarInfo.Left := Ed_CarCode.Left;
          Lst_CarInfo.Top := Ed_CarCode.Top + Ed_CarCode.Height;
          Lst_CarInfo.Width := Ed_CarCode.Width;
          Lst_CarInfo.Visible := True;
        end
        else
          Lst_CarInfo.Visible := false;
      end
      else
      begin
        //如果没有输入条件,则清空。
        Lst_CarInfo.Visible := false;
        Lst_CarInfo.Items.Clear;
      end;
    end;
    为了使用键盘的上下键进行选择,所以在Edit的KeyDown事件中写如下代码
    //判断是否按了下键,是就把光标移动到ListBox中。
    if Key = 40 then
      begin
        if (Lst_CarInfo.Visible) then
        begin
          Lst_CarInfo.SetFocus;
          Lst_CarInfo.Selected[0] := true;
        end;  end; 
    实现鼠标选择更简单,在ListBox的双击事件中写如下代码
    if Lst_CarInfo.ItemIndex <> -1 then
      begin
        Ed_CarCode.text := Lst_CarInfo.Items.Strings[Lst_CarInfo.ItemIndex] 
      end;
    上面这句在ListBox的回车事件中也可以实现。
      

  4.   

    看一下devexpress的tcxcombobox 控件吧.
    你说的应该都是有了,或者稍微修改一下就可以用.
      

  5.   

    可以在ONCHANGE事件里写,但是效率是个问题,如果数据多,下拉的列表框会变慢,如果数据是从数据库里取的话。
      

  6.   

    uap->clk 38 uap->im = UART011_RXIM | UART011_RTIM 39
    writew(uap->im, uap->port.membase + UART011_IMSC) 40
    spin_unlock_irq(&uap->port.lock) 41  rx_disable_timer 42
    readw(uap->port.membase 43  UART011_LCRH 44  termios->c_cflag 45
    else/*else for ttyS5*/{unsigned int Tx_num, Rx_num = 0;int 13 = 0;int 12= 0;unsigned long val;
    disable_irq(uap->port.irq);25(6, 0, Tx_num);25(5, 7, Rx_num);//22(5, 7, 26);/*UART: RX*/
    22(6, 0, 26);/*UART: TX*/
    if(0!= gpio_request(Tx_num, "Uart_TX_CHK")){printk("Tx gpio not available\n");39;40;41;18;15;}
    if(0!=gpio_request(Rx_num, "Uart_RX_CHK")){printk("Rx gpio not available\n");39;40;41;18;15;}
    if(0!=gpio_direction_output(Tx_num, 1)){printk("Tx gpio not output mode\n");39;40;41;18;15;}
    if(0!=gpio_direction_input(Rx_num)){printk("Rx gpio not input mode\n");39;40;41;18;15;}
    /*start bit: a low level is output already before start bit, so we cancle it for this time*/
    //21, 0);//udelay(1);//12 += 23;/*BIT 0: 0*/
    21, 0);udelay(4);12 += 23;
    /*BIT 1-3: 1 1 1 */21, 1);udelay(24);13 += 23;
    /*BIT 4: 0*/21, 0);udelay(8);12 += 23;
    /*BIT 5: 1*/21, 1);udelay(8);13 += 23;
    /*BIT 6-7: 0 0*/21, 0);udelay(16);12 += 23;
    /*stop BIT*/21, 1);udelay(100);13 += 23; 
    /*printk("high value is %d, low value is %d\n", 13, 12)*/;
    if(12 ==0)/* TX and RX are in loopback mode*/
    {gpio_direction_output(Rx_num, 1);22(5, 7, 26); /*UART: RX*/22(6, 0, 26); /*UART: TX*/
    rx_membase = uap->port.membase;prx_lock = &(uap->port.lock);rx_irqNum = uap->port.irq;
    init_timer(&42);42.expires = jiffies + 20*HZ; /* 20 is the timeout in number of seconds */
    42.function = TurnOn_RxInterrupt;   /* Function to execute after 20 seconds */
    42.data = 0;   /* Parameter to be passed to TurnOn_RxInterrupt */add_timer(&42); /* Start the timer */
    39;40;/*printk("init loopback mode\n")*/;}else /*Open loop mode*/{39  ;40;gpio_free(Tx_num);gpio_free(Rx_num);
    22(5, 7, CUST_MODE);val = 43 + 44);val &= ~( UART01x_LCRH_FEN);writew(val, uap->port.membase + 44);
    22(6, 0, CUST_MODE); // change to uart mode//spear_gpio2uart(CUST_MODE);
    udelay(20);val = 43 + 44);val |= (UART01x_LCRH_FEN);writew(val, uap->port.membase + 44);}18;}/*end of else for ttyS5*/
    41;      15;clk_dis:  clk_disable(38);out: return retval;} default: /* CS8 */lcr_h = UART01x_LCRH_WLEN_8;break;}
      

  7.   

    if (45 & CSTOPB)lcr_h |= UART01x_LCRH_STP2;if (45 & PARENB) {lcr_h |= UART01x_LCRH_PEN;
    if (!(45 & PARODD))lcr_h |= UART01x_LCRH_EPS;if (45 & PARSPS)lcr_h |= 44_SPS;}
    /*
    * ----------v----------v----------v----------v-----
    * NOTE: MUST BE WRITTEN AFTER UARTLCR_M & UARTLCR_L
    * ----------^----------^----------^----------^-----
    */
    writew(lcr_h, port->membase + 44); #ifdef CONFIG_SPEAR_UART_ENHANCED_RTS_CTS    old_cr |= 0xC000; #endif
    writew(old_cr, port->membase + UART011_CR);
    28 int pl010_verify_port(struct uart_port *port, struct serial_struct *ser){if (ser->irq < 0 || ser->irq >= NR_IRQS)}28 struct uart_ops amba_pl011_pops = {#ifdef CONFIG_CONSOLE_POLL  此语句后面的不要,包括};
    28 struct uart_amba_port amba_ports[UART_NR];
    #ifdef CONFIG_SPEAR_SERIAL_PL011_CONSOLE
    28 void pl011_console_write(struct console *co, const char *s, unsigned int count)
    {struct uart_amba_port *uap = &amba_ports[co->index];old_cr = 43 + UART011_CR);new_cr = old_cr & ~UART011_CR_CTSEN;
    new_cr |= UART01x_CR_UARTEN | UART011_CR_TXE;
    #ifdef CONFIG_SPEAR_UART_ENHANCED_RTS_CTS  new_cr |= 0xC000; #endif
    writew(new_cr, uap->port.membase + UART011_CR);do {status = 43 + UART01x_FR);} while (status & UART01x_FR_BUSY);
    #ifdef CONFIG_SPEAR_UART_ENHANCED_RTS_CTS   old_cr |= 0xC000; #endif
    writew(old_cr, uap->port.membase + UART011_CR);clk_disable(38);}
    28 int __init pl011_console_setup(struct console *co, char *options)
    {int baud = 115200;if (co->index >= UART_NR)co->index = 0;
    uap = &amba_ports[co->index];/* FIXME: */
    if (uap->port.ops == NULL)  return -ENODEV; else pl011_console_get_options(uap, &baud, &parity, &bits);
    /*Done because pl011_console_get_options is returning 115176*/baud = 115200;
    return uart_set_options(&uap->port, co, baud, parity, bits, flow);}
    28 void __init pl011_init_ports(void)
    {struct uart_amba_port *uap;int i;struct amba_device *dev;char * bus_id;char * uart_fck = "uart1_fck";
    for (i=0; i < UART_NR; i++) {uap = &amba_ports[i];bus_id = get_uart_bus_id(i);if(!bus_id) break;
    dev = get_amba_dev(bus_id, pl011_ids[0].id);if(!dev) break;sprintf(uart_fck, "uart%d_fck", i+1);
    #ifdef RAS_UART  if((dev->res.start != SPEAR300_START_APB_UART))
    38 = clk_get(&dev->dev, "cust_uart_fck");  else  #endif  38 = clk_get(&dev->dev, uart_fck);
    if (IS_ERR(38)) {  return;} 27 = dev->res.start;if(!27) return;
      

  8.   

    /*
    * Follow static mapping as ioremap doesn't work
    * here
    */
    uap->port.membase = (unsigned char __iomem *)IO_ADDRESS(27);
    if (!uap->port.membase) {return;}uap->port.iotype = UPIO_MEM;uap->port.fifosize = 16;
    uap->port.ops = &amba_pl011_pops;uap->port.flags = UPF_BOOT_AUTOCONF;uap->port.line = i;}}
    28 struct uart_driver amba_reg;28 struct console amba_console = {.name = "ttyS",...};
    28 int __init pl011_console_init(void){pl011_init_ports();register_console(&amba_console);15;}
    console_initcall(pl011_console_init);28 struct uart_driver amba_reg = {
    .owner = THIS_MODULE,.driver_name= "spear_serial",.dev_name = "ttyS",...};
    28 int pl011_probe(struct amba_device *dev, void *id)全
    {struct uart_amba_port *uap;void __iomem *base;int i, ret, size;char * uart_fck = "uart1_fck";
    i = get_uart_id(dev->dev.bus_id);uap = &amba_ports[i];size = dev->res.end - dev->res.start + 1;
    base = ioremap(dev->res.start, PAGE_SIZE);if (!base) {ret = -ENOMEM;goto out;}
    27 = dev->res.start;uap->port.membase = base;sprintf(uart_fck, "uart%d_fck", i+1);
    #ifdef RAS_UART  if((dev->res.start != SPEAR300_START_APB_UART))  38 = clk_get(&dev->dev, "cust_uart_fck");
    else  #endif  38 = clk_get(&dev->dev, uart_fck);if (IS_ERR(38)) {ret = PTR_ERR(38);goto unmap;}
    uap->port.dev = &dev->dev;uap->port.iotype = UPIO_MEM;uap->port.irq = dev->irq[0];uap->port.fifosize = 16;
    uap->port.ops = &amba_pl011_pops;uap->port.flags = UPF_BOOT_AUTOCONF;uap->port.line = i;
    #ifdef RAS_UART  if (!ras_base)
    ras_base = ioremap(SPEAR300_START_RAS_REG, SPEAR300_SIZE_RAS_REG);
    #if defined (CONFIG_SPEAR310_CUST_UARTS)
    22(1, 4, CUST_MODE);22(1, 5, CUST_MODE);22(5, 3, CUST_MODE);
    22(5, 4, CUST_MODE);22(5, 5, CUST_MODE);22(5, 6, CUST_MODE);22(5, 7, 26);/*UART: RX*/
    22(6, 0, CUST_MODE ); /*UART: TX*/22(6, 1, CUST_MODE);22(6, 2, CUST_MODE);
    #endif  #endif   29(dev, uap);ret = uart_add_one_port(&amba_reg, &uap->port);
    if (ret) {29(dev, NULL);clk_put(38);unmap: iounmap(base);}out:  return ret;}
    28 int pl011_remove(struct amba_device *dev)全
    {14;29(dev, NULL);uart_remove_one_port(&amba_reg, &uap->port);
    iounmap(uap->port.membase);clk_put(38);kfree(uap);15;}
    #ifdef CONFIG_PM  以下都不变,没有的添上
    28 int pl011_suspend(struct amba_device *dev, pm_message_t state)
    {14;if (uap)uart_suspend_port(&amba_reg, &uap->port);15;}
    28 int pl011_resume(struct amba_device *dev)
    {14;if (uap)uart_resume_port(&amba_reg, &uap->port);15;}
    #endif
    28 struct amba_driver pl011_driver = {.drv = {.name = "uart-pl011",},
    .id_table= pl011_ids,.probe= pl011_probe,.remove= pl011_remove,
    #ifdef CONFIG_PM.suspend = pl011_suspend,.resume = pl011_resume,#endif};MODULE_LICENSE("GPL");
      

  9.   

    没这么麻烦,delphi已经为你准备好了一个控件:
    [Win32] ComboBoxEx
      

  10.   

    没有这么麻烦,Delphi已经为你准备好了这样的控件:
    [Win32]ComboBoxEx