Search Combo Box as Google Search

I am doing Windows Form in that I have a combo box in which I loaded some “account numbers” from SQL Server 2010. I want to display account numbers as users in the “Combo” field. For example, if the user types are "100", then the account numbers starting with "100" should be displayed in the drop-down list.

Please help, Thanks in Advance ...

+5
source share
4 answers
    DataTable temp;
    DataTable bank;
    private void Form1_Load(object sender, EventArgs e)
    {
        comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
        comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems;

        temp = DbRdRw.SqlDbRead("Select * from BankMaster", "BankMaster");

        DataView dtview = new DataView(temp);
        dtview.Sort = "BankName DESC";
        bank = dtview.ToTable();

        comboBox1.DataSource = bank;
        comboBox1.ValueMember = "BankName";
        comboBox1.DisplayMember = "BankName";
    }
+8
source

Fill in the combo box with items from the database at startup, then set the Combo box properties:

AutoCompleteMode : Suggest Add

AutoFill : ListItems

DropDown DropDown, . , .

, .

+3

AutoCompleteMode - Suggest, SuggestAppend , . , AutoCompleteSource , AutoComplete ( ListItems).

http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.autocompletemode.aspx

+1

, :

  • , .
  • , , ( "100" ) , :

    SELECT InvoiceNumber from Invoices WHERE InvoiceNumber LIKE '100%'

  • Display the matching results back in the combo box for selection by the user.
+1
source

All Articles