Click here to Skip to main content
15,908,673 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
while key in a word, I want to bind the data from sql table and want to automatically come out the list on combobox

My code is here.Can't automatically show the list of data on combobox.
Help me.

C#
 private void SearchItem(string item)
        { 
               DataSet data = new DataSet();
            DataTable table = new DataTable();
            data = logic.GetData_By_Desc("SearchbyProductDescription", item);
            table.Rows.Clear();            
            table = data.Tables[0];            
            cboSearch.DataSource = table;
            cboSearch.DisplayMember = "Description";
            cboSearch.ValueMember = "id";          
            cboSearch.DroppedDown = true;
}
private void cboSearch_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
            {
                string item = cboSearch.Text;
                SearchItem(item);}

}

ttds
Posted
Updated 18-Mar-13 6:13am
v2
Comments
Prasad Khandekar 18-Mar-13 14:55pm    
How about using SelectedIndexChanged event handler instead of KeyDown.

1 solution

You have to use some different key instead of ENTER for submitting the search. When you press ENTER, the ComboBox will collapse its DroppedDown list. That is system behaviour.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900