Take into account that this is a hack. I managed to solve that problem and the lack of API functionality doing a trivial and nasty thing. I'll show you this with code:
dim source as AutoCompleteStringCollection = new AutoCompleteStringColection()
dim values() as String = new String() {" Monday", _
" Tuesday", _
" Wednesday", _
" Thursday", _
" Friday", _
" Saturday", _
" Sunday" }
TextBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend
TextBox1.AutoCompleteSource = AutoCompleteSource.CustomSource
TextBox1.AutoCompleteCustomSource = source
That is, prepend a whitespace to every string in the autocomplete list. Then, it's your knowlodge about that fact and use it for your convenient objective.
For example, you could add a whitespace in the TextBox
when clicked, focused, etc. (Note that this could be done with any character. The idea is to know that every string in the autocomplete list begins with the same character)
You MUST be aware of that. In fact, consider extending TextBox
form and manage the correct trimming of the inputed string.
Again, called this recommended or not is at your own decision. What this answer tends to do, is to solve the problem of wanting a TextBox
drops down a suggestion list without starting typing with the restrictions of the API, also called, a workaround or ugly-hack.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…