I need a c# (vs-2019) code to get a auto-completion of combobox match any part of string not only start of string. For example (in a vehicle nos populated combo) if the user enters '84' the combo should suggest / lists all the vehicle numbers those contains the entered number any part of the vehicle numbers, like TN22CC9846, KA13AD8467, TN07AD1846, etc.
ComboBox or Textbox AutoComplete on SubString
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Rajeesh MenothRank #118 · 18.4K reputationPosted Nov 14, 2024, 11:00 PM EST
Hi Yuva,
You can go through this article included source code.
https://www.codeproject.com/Tips/631196/ComboBox-with-Suggest-Ability-based-on-Substring-S
Charles Henington54 reputationPosted Nov 15, 2024, 1:13 AM EST
public static IEnumerable GetMatches(string[] items, string pattern)
{
if(items == null || items.Length == 0) yield break;
foreach(var match in items)
{
if (match.Contains(pattern)) yield return match;
}
}