2
votes

In VB.NET for the combo box, I have set the autocomplete mode to "SuggestAppend" and autocomplete source to "ListItems". Its working as expected. But the width of the autosuggest dropdown box is not same as that of combo box and so it looks weird.

I tried changing the value dropdown width property but it changes the value of normal dropdown box (seen after clicking down arrow on combobox), and not the autosuggest dropdown box.

So what code or property needs to be set to make autosuggest dropdown box the same width as that of combobox width? This image shows difference between the width of autosuggest dropdownbox and that of combobox width

This images show normal dropdown box , width of which is controlled by dropdown width propery of combobox

1

1 Answers

2
votes

Look real closely and you'll notice that its width is user-customizable. The resizing grip at the lower right corner is the dead giveaway:

     resizing grip indicated with a freehand circle

There's no built-in option to specify the width, and that's by design. Under the covers, the ComboBox control actually uses the SHAutoCompleteAPI function to implement this functionality. The auto-suggest box always displays with the last width chosen by the user. It can just as easily appear much larger than the width of the combo box.

If you really wanted to do this, you could subclass the ComboBox control, P/Invoke a bunch of functions from the Windows API, and get the handle to the auto-suggestion box window, which you could then resize. But the code is ugly, and it's hardly worth the trouble. Sample code is available on this thread.