Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
C# combobox (search anywhere within list, not just first letter autocomplete) using with windiows form applicaiton
Posted 14-Jan-13 18:18pm
ttds801
Comments
David_Wimbley at 14-Jan-13 23:19pm
   
What list are you talking about? A list box control list? The list of items that pops open when you type in a combo box?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
 
In WPF[^]
In Windows[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

private void comboBox1_KeyUp(object sender, KeyEventArgs e)
        {
            //index of taped text
            int index;
            //text found
            string found;
            //text written
            string actual;
 
            //to avoid these keys
            bool bo = e.KeyCode == Keys.Back || e.KeyCode == Keys.Left
            || e.KeyCode == Keys.Right || e.KeyCode == Keys.Up || e.KeyCode == Keys.Down
            || e.KeyCode == Keys.Delete || e.KeyCode == Keys.PageDown
            || e.KeyCode == Keys.PageUp || e.KeyCode == Keys.End
            || e.KeyCode == Keys.Home;
 
            if (bo == true)
                return;
 
            actual = this.comboBox1.Text;
            index = this.comboBox1.FindString(actual);
 
            //this condition means that there is a result
            if (index > -1)
            {
                found = this.comboBox1.Items[index].ToString();
                this.comboBox1.SelectedIndex = index;
 
                this.comboBox1.SelectionStart = actual.Length;
                this.comboBox1.SelectionLength = found.Length;
                this.comboBox1.DroppedDown = true;
 
            }
        }
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 330
1 Sergey Alexandrovich Kryukov 279
2 BillWoodruff 245
3 Afzaal Ahmad Zeeshan 215
4 CPallini 205
0 OriginalGriff 5,635
1 DamithSL 4,496
2 Maciej Los 3,942
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,180


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 28 Jun 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100