能否做到。??

解决方案 »

  1.   

    private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
    {
    if(e.KeyCode==Keys.Enter&&this.textBox1.Text!="")
    {
    int j=this.textBox1.Text.Length;
    for(int i=0;i<this.listView1.Items.Count;i++)
    {
    try
    {
    if(this.listView1.Items[i].Text.Length>=this.textBox1.Text.Length&&this.listView1.Items[i].Text.Substring(0,j).ToUpper()==this.textBox1.Text.ToUpper())
    {

    this.textBox1.Text=this.listView1.Items[i].Text;
    this.listView1.Visible=false;
    return;
    }
    }
    catch
    {
    //MessageBox.Show("输入有误1!");
    this.listView1.Visible=true;
    this.textBox1.Clear();
    }
    }

    MessageBox.Show("输入有误2!");
    this.listView1.Visible=true;
    this.textBox1.Clear();
    }
    }