监测用户输入,如果有下一个keyup事件,就马上结束当前的查询和显示,如果没有下一个keyup事件马上根据新的内容进行查询或显示。

解决方案 »

  1.   

    在输入的控件上加keyup事件就可以了呀?
      

  2.   

    private void comboBox1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
    {
    if(e.KeyValue.ToString()!="8"&&e.KeyValue.ToString()!="37"&&e.KeyValue.ToString()!="38"&&e.KeyValue.ToString()!="39")
    {

    if(this.comboBox1.Items.Count > 0)
    {
    for(int i=0 ;i< this.comboBox1.Items.Count;i++)
    {
    this.comboBox1.Items.RemoveAt(i);
    }

    }

    if(this.comboBox1.Items.Count > 0)
    {
    for(int i=0 ;i< this.comboBox1.Items.Count;i++)
    {
    this.comboBox1.Items.RemoveAt(i);
    }
    }

    DataFuil(this.comboBox1.Text);

    for(int i=0 ;i<dt.Rows.Count;i++)
    {
    this.comboBox1.Items.Add(""); }

    for(int i=0 ;i<dt.Rows.Count;i++)
    {
    this.comboBox1.Items[i]= dt.Rows[i]["CityName"].ToString();
    // this.comboBox1.Items.Add(dt.Rows[i]["CityName"].ToString());
    }
    }
    this.comboBox1.DroppedDown = true; }