ComboBox Should Allow Only ComboBox Listed Items While Typing In C#
In Winforms..In My ComboBox I have 100 Items. While I Am Typing In The ComboBox It Should Accept.But When I Typed A Text That Is Not In the ComboBox Items, Then It Should Show A MessageBox That Is "The Item Is Not In The List"...Please Help Me.....


Rakesh Kaushik29 reputationPosted Feb 27, 2013, 9:15 PM EST
at last found one.
Very simple dear, just use findstring method in leave event.
int index = combobox1.FindString(combobox1.Text);
if (index < 0)
{
MessageBox.Show("Invalid Record");
combobox1.Focus();
return;
}
Cheers
VulpesRank #55 · 29.2K reputationPosted Sep 21, 2012, 2:45 PM EDT
FWIW, you'd need to handle the TextChanged event and the code would be something like this:
CHAITANYA KIRAN KASANIRank #4,018 · 371 reputationPosted Sep 21, 2012, 10:33 PM EDT