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.
Loading
Charles HeningtonPosted Nov 15, 2024, 6:13 AM
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;
}
}
Rajeesh MenothPosted Nov 15, 2024, 4:00 AM
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