سؤال

I have a simple textbox containing "Names":

  1. Set AutoCompleteSource to "CustomSource" (in Properties of the textBox)
  2. AutoCompleteMode to "SuggestAppend" (in Properties of the textBox)

If I try to manually add a value to the AutoCompleteCustomSource-Collection, it works. But now I tried this:

NameTextBox.AutoCompleteCustomSource.Add(NameTextBox.Text);

And nothing happens. Did I forget something?

Thanks in advance

هل كانت مفيدة؟

المحلول

This is what my mistake was. I thought that this Atocompletecollection would behave like the browsers textcompletion and save the strings forever even after restarting the programm. Namely that once the string has been added to the collection it will persist forever like *.resx stuff does. Obviously I was wrong.

I got another solution for my problem:

To be presice the textbox belongs to a form the user has to fill in when he/she is making a db-entry. So why I needed the AutoComplete-collection is obvious too.

I solved this problem by populating the collection with strings (from db-entries), every time the form that contains the textbox is instatiated.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top