我有一个带有文本框的窗体,其工作方式类似于谷歌搜索,我有一个存储过程,在列表中返回注册,我使用AutoComplete
方法中的列表,我面临的问题我希望在用户输入注册时显示3列我想在下拉列表中显示帐户和所有者名称,如此注册|帐户|所有者,但只能通过注册进行搜索。
这是我的StoredProcedure方法
public static List<string> GetAircraftRegistrationList()
{
List<string> list = new List<string>();
Database db = DatabaseFactory.CreateDatabase("GCA");
DbCommand dbCommand = db.GetStoredProcCommand("GetAircraftRegistrationList");
using (IDataReader dataReader = db.ExecuteReader(dbCommand))
{
while (dataReader.Read())
{
list.Add(dataReader["Registration"].ToString());
}
}
return list;
}
这是我的自动填充
public static void LoadAircraft(TextBox autocompleteTextBox)
{
AutoCompleteStringCollection list = new AutoCompleteStringCollection();
autocompleteTextBox.AutoCompleteMode = AutoCompleteMode.Suggest;
autocompleteTextBox.AutoCompleteCustomSource = list;
autocompleteTextBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
list.AddRange(Aircraft.GetAircraftRegistrationList().ToArray());
}
这适用于注册。我如何将帐户和所有者显示在文本框中作为3列
所以我想在文本框中这样做:
目前,无论您如何切片,如果您输入“ab”,您将获得一份清单......
"Abacas"
"Abate"
"Abbrv."
使用多列选项,您可以输入“ch”并获取...
"Chris A. | (656) 573-7834 | Blue"
"Christine B. | (656) 458-9823 | Purple"
"Charisma C. | (656) 645-7823 | Green"
答案 0 :(得分:-1)
请改用以下查询。
Dim com As New SqlCommand("Select Registration,Account,Owner from Registry where name like % " & txtbox.Text & " % ",conn)
Dim da As New SqlDataAdapter(com)
Dim ds As New DataSet
da.Fill(ds)
reg_drop.DataSource=ds.Tables(0)
reg_drop.DisplayMember="Registration"
reg_drop.ValueMember="Registration"
Account_drop.DataSource=ds.Tables(0)
Account_drop.DisplayMember="Registration"
Account_drop.ValueMember="Registration"