views:

360

answers:

1

I have an application with a lot of TextBox controls that use autocomplete. Each one uses AutoCompleteMode.CustomSource to get the autocomplete text from an associated AutoCompleteStringCollection.

Whenever the user enters a new value in the TextBox, it gets added to the associated AutoCompleteStringCollection, and at the end of the session all of those collections get persisted to a file in the user's home directory.

The problem is that there's no way to correct errors in those collections. In IE, input controls with autocomplete controls let you scroll to an item in the autocomplete list and press Del to remove it. That doesn't work in the .NET controls.

I'd really like to avoid having to implement my own UI for this. Am I stuck? Is there a way to enable this that I'm not seeing?

+1  A: 

Out of the box, no there's nothing to do this for you unfortunately. I tried P/Invoking the basic FindWindowEx / EnumChildWindows to see if I can get a Handle to the actual drop down, but was unsuccessful (if someone does manage to pull this off, let me know!). The good news is (not so good, but not terrible) that the auto complete isn't actually something you completely have to implement yourself, there's actually a Win32 function called SHAutoComplete that can be P/Invoked to help you with the auto completion. Don't get too excited yet, because it's not as simple as just P/Invoking it and be done with it. However, there's a great CodeProject article that should help you out tremendously.

BFree
That's an outstanding article, and thanks. This is clearly going to take some digging.
Robert Rossney