C# 如何实现可以为我的windows窗体应用程序搜索子字符串的自动完成组合框?
在图片中,当我按下I时,它显示了I的所有书籍。但我想搜索 从子字符串开始,就像我想要所有包含印度的书籍一样 在我的程序中,数据是从数据库中提取的。它已经从一开始就在搜索,但现在我想从中搜索任何子字符串。下面给出了代码,请帮助我匹配它C# 如何实现可以为我的windows窗体应用程序搜索子字符串的自动完成组合框?,c#,search,combobox,autocomplete,substring,C#,Search,Combobox,Autocomplete,Substring,在图片中,当我按下I时,它显示了I的所有书籍。但我想搜索 从子字符串开始,就像我想要所有包含印度的书籍一样 在我的程序中,数据是从数据库中提取的。它已经从一开始就在搜索,但现在我想从中搜索任何子字符串。下面给出了代码,请帮助我匹配它 sRetVal = GlobalFuncs.GetPersonListWithCondition(ref dtPerson, Convert.ToString(cboPersonCategory.SelectedValue)); if (sRetVal == Gl
sRetVal = GlobalFuncs.GetPersonListWithCondition(ref dtPerson, Convert.ToString(cboPersonCategory.SelectedValue));
if (sRetVal == GlobalFuncs.SUCCESS)
{
var source = new AutoCompleteStringCollection();
source.AddRange(dtPerson.AsEnumerable().Select<System.Data.DataRow, String>(x => x.Field<String>("PersonName")).ToArray());
cboPerson.AutoCompleteCustomSource = source;
cboPerson.DataSource = dtPerson;
cboPerson.AutoCompleteMode = AutoCompleteMode.Suggest;
cboPerson.DisplayMember = "PersonName";
cboPerson.ValueMember = "PersonID";
}
else
{
MessageBox.Show(sRetVal);
return;
}
sRetVal=GlobalFuncs.GetPersonListWithCondition(ref-dtPerson,Convert.ToString(cboPersonCategory.SelectedValue));
if(sRetVal==GlobalFuncs.SUCCESS)
{
var source=new AutoCompleteStringCollection();
AddRange(dtPerson.AsEnumerable().Select(x=>x.Field(“PersonName”)).ToArray();
cboPerson.AutoCompleteCustomSource=source;
cboPerson.DataSource=dtPerson;
cboPerson.AutoCompleteMode=AutoCompleteMode.Suggest;
cboPerson.DisplayMember=“PersonName”;
cboPerson.ValueMember=“PersonID”;
}
其他的
{
MessageBox.Show(sRetVal);
回来
}
您是否收到任何错误消息?如果没有,你做了什么来实现所需的功能?没有,没有错误,但根据要求,我想让它也能够搜索子字符串。现在从第一个字母开始搜索如果你能给出你当前功能和所需功能的示例,我真的可以尝试提供帮助。这里已经询问过,可能会帮助你:好的,我添加当前功能的图像