harry code

harry code

  • NA
  • 124
  • 23k

KeyPress event in ComboBox

May 11 2018 4:02 AM
Hi,
I am working on Combobox.
I need to search by typing the character in the combobox by using linq.
I am using a gridview to display the data fro a table. 
i have written the following code under ComboBox_KeyPres  event
 
{
string combotext = comboBox1.Text;
dataGridView1.DataSource = from em in dc.emps where em.dept.Contains(combotext ) select em;
}
 
once i enter the character like 'A','D'  etc the value is not getting stored in the variable Combotext.
after the keypress event is completed the value is getting stored into the variable.
 
I want the value to stored immediately after entering it into the Combobox.
 
Thank you

Answers (2)