0

I would like autocomplete to work like Contains method

private void Form1_Load(object sender, EventArgs e)
{
    // Create the list to use as the custom source. 
    var source = new AutoCompleteStringCollection();
    source.AddRange(new string[]
                    {
                        "January",
                        "February",
                        "March",
                        "April",
                        "May",
                        "June",
                        "July",
                        "August",
                        "September",
                        "October",
                        "November",
                        "December"
                    });

    // Create and initialize the text box.
    var textBox = new TextBox
                  {
                      AutoCompleteCustomSource = source,
                      AutoCompleteMode = 
                          AutoCompleteMode.SuggestAppend,
                      AutoCompleteSource =
                          AutoCompleteSource.CustomSource,
                      Location = new Point(20, 20),
                      Width = ClientRectangle.Width - 40,
                      Visible = true
                  };

    // Add the text box to the form.
    Controls.Add(textBox);
}

Want Autocomplete textbox if match any part return contain result. For Ex. When I enter "pr", the result show "April".

zura
  • 11
  • 9
  • 1
    I found several posts on the internet and SO like [this](https://stackoverflow.com/questions/7985620/autocomplete-contains-instead-of-starting-with-in-winform-textbox) and [this](https://stackoverflow.com/questions/43254621/customize-textbox-autocomplete), most of them tell that you have to do it manually and some propose to use a different control like a combobox but the manual part remains. – Mong Zhu Nov 02 '20 at 07:55
  • I Found these solutions too, but I can't believe it can't be done with following solution. – zura Nov 02 '20 at 18:21

0 Answers0