0
votes

let's say that I have items as it:

PHP Hypertext Processor
PHP_FOO PHP framework
C#  .NET framework 
Obama american
Bill gates american

I'm looking for a way to that any text entered in comobobox search in any part of combobox items, not only in start of string and set it into auto-completation suggest.

For example:

text entered: Processor or PHP or Hypertext match: PHP Hypertext Processor text entered: american match: Obama and Bill gates etc..

The matches items should be defined as suggestion in combobox.

UPDATE my current code:

 private void comboBox1_TextChanged(object sender, EventArgs e)
    {
        int i = 0;
        foreach(object item in comboBox1.Items)
        {
            string val = (string)item;
            string[] words = val.Split(' ');

            foreach (string word in words)
            {
                if (word == comboBox1.Text)
                {
                    ////the difficult now it is as set the val variable value in combobox suggestions box?
                }
            }

            i++;
        }

    }

how I do it? I hope this is clear. Thanks in advance.

1
@DJKRAZE:is not. you can post an example how do it? the difficult is show stirng as suggest in comobobox.Jack
you can do this many ways... check on the key press or key up events. I would use an or create a string[] along with a switch statement.. what code have you tried so far.. you have to be willing to try coding something first..MethodMan
since you state that you are looking for any word that is contained in that string variable look at the .Contains methodMethodMan
I think you can't handling with suggestion box of control.Kakashi

1 Answers

0
votes

your loop should be changed as well.. if you know that it will have text use something like this for starters.

foreach (string text in combobox1.Items.Cast<string>())
{
     //do stuff with the text
}