开发者

Event for TextBox Value Not Matched with any Value in AutoCompleteDataSource

开发者 https://www.devze.com 2023-02-03 05:15 出处:网络
I\'ve a TextBox as below textBox.AutoCompleteCustomSource = GetAutoCompleteStringCollection(); textBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;

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
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消