I've a TextBox as below
textBox.AutoCompleteCustomSource = GetAutoCompleteStringCollection();
textBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
textBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
When user provided value is not present in the list of auto complete,开发者_如何学Go I want to give an option for user add new item. So how do I know that user entered value is not present in the datasource? Is there any event for that or any other way I can know?
textBox1.Validated += new EventHandler(textBox1_Validated);
void textBox1_Validated(object sender, EventArgs e)
{
if(GetAutoCompleteStringCollection().Contains(textBox1.Text) == false )
{
// Do your Add-New-Item option
}
}
精彩评论