2014-04-07 209 views
-1

我有工作方式類似於谷歌搜索文本框Windows窗體,我已經在列表中返回一個註冊的存儲過程,我用在AutoComplete方法列表,我的問題面對的,是我想3列到當用戶輸入我想說明的賬號和所有者名稱在下拉列表中登記所以像這樣的註冊證明|賬戶|業主,但只能通過註冊搜索。自動完成文本框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" 

回答

-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"