简体   繁体   中英

Autocomplete combobox - item on the list?

i'm using combobox with autocomplete option, where autocompletesource is ListItems and AutoCompleteMode is SuggestAppend.

I'm trying to load from combobox item called: 51420283V. When I hit enter app loads data from 51420283V. When i trying to load item, which is not in my combobox i'm getting error. So i'd like to check first if the number/string text is on my combolist. Example: 1123232 is not on my list. I accidentaly hit enter, and application is trying to load items from 1123232.. and error ;)

I'm trying something like that, but with many errors:

        if (e.KeyCode == Keys.Enter)
          {
                if (ReferenceCombo.Contains(ReferenceCombo.SelectedText))
                {

                }
                else MessageBox.Show("Item not in combolist");
             }

Why not catch the error on when you are loading the item?...I mean, before loading the item. xD

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM