ComboBox List Drop-Down not showing?
I have a combobox set to list (that means it acts as only a dropdown, not an edit control), and I have added 3 items to it, but when I click the combo box to show the drop down list, all I see is a small black line appear right below the combo box, and no list!
What do I have to do to fix this?
I figured other people had encountered this issue before, so I didn't bother posting any code. I have a wrapper class for combo boxes, so it would look a bit messy if I posted it. Nevertheless, if you need code, please request it!
Re: ComboBox List Drop-Down not showing?
Open your dialog in your resource editor and vertically resize your combox box. You probably have a 0-size height for your drop list.
Re: ComboBox List Drop-Down not showing?
There is a small trick: Click in the resource editor on the button of the combobox. This will enable to change the size of the listbox. Just size it vertically then. With clicking on the button again will help you to get back to the original state.
Re: ComboBox List Drop-Down not showing?
If you create combo dynamically, set rectangle width (top, bottom) to desire drop list height.
Re: ComboBox List Drop-Down not showing?
Hi all,
is there any other way to set the size of dropdown list automatically/dynamically, something like "CB_Autoheight" or so? Do i really have to send the CB_SETITEMHEIGHT meessage each time i add or remove an item?
thx
berkov
.
Re: ComboBox List Drop-Down not showing?
You don't need to send anything once you set up the combobox's drop-down size in resource editor.
Re: ComboBox List Drop-Down not showing?
I know but the items are added dynamically during the runtime.
The time of creating the CB, i don;t know what the number of elements it will contain.
Re: ComboBox List Drop-Down not showing?
Quote:
Originally Posted by
berkov
I know but the items are added dynamically during the runtime.
The time of creating the CB, i don;t know what the number of elements it will contain.
But in any case your dropdown should be displayed inside (and not outside!) the visible area of your monitors.
Re: ComboBox List Drop-Down not showing?
Hi Victor
Sorry, i'm afraid i didnt really get the point here.
Let me explain again.
I've created the Dialog with the following entry in resources.rc:
Code:
COMBOBOX IDC_inv_type, 65, 28, 72, 15, CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_TABSTOP
The Dialog is shown to the user and base on his/her interaction (choice) the CB is being updated (btw - by using that ADO you helped me with). Now, because the size is still set to 15, the elements in dropdown list are not shown to the user so i need to "extend" it accordingly to the number of items added.
I've tried to manually (in the resources.rc) set the 15 to e.g. 100 pixels but then the list after rolling down is always 100pix long which does not look too pretty (if the user adds e.g. only 3 entries). So this is the reason i wanna have it dynamically resized.
I've went thru the MSDN doc and could not find any param that woudl do the resizing automatically on the update and the only one way seems to be CB_GETITEMHEIGHT + new pixels = CB_SETITEMHEIGHT. and of course i can do it this way but i wanna learn C++ and some good practices (like no unnecessary code) so no "workarounds" are allowed! :-)
Re: ComboBox List Drop-Down not showing?
Well, have a look at this example: A Dynamically-Resized Combo Box
It is MFC, but you could do the same with plain Win32. Just subclass a combobox and implement a procedure to resize window by its dropdown...
Re: ComboBox List Drop-Down not showing?
hmm so it means that there is no automatic way and this needs to be coded.
example given by you looks good and does it by usign the SetWindowPos where CB is the window, i was going to do very similar thing by using CB_SETITEMHEIGHT. i will check at home and past the final code.
thanks for the time and help
Re: ComboBox List Drop-Down not showing?
Quote:
Originally Posted by
berkov
I know but the items are added dynamically during the runtime.
The time of creating the CB, i don;t know what the number of elements it will contain.
You don't have to know that. What you set up is the height of the dropping down list. In case current items fit into the height, it will depend on the number of items in the list. But once those overall height exceeds the predefined height, the list will show scroll bar, but the predefined height remains unchanged.
Quote:
Originally Posted by
berkov
hmm so it means that there is no automatic way and this needs to be coded.
The dynamically growing list height contradicts with basic Windows UI design guidelines, so breaking the rules must be thought out very thoroughly.
Re: ComboBox List Drop-Down not showing?
@Igor,
just tried this.
i even updated the CB to have the autoscroll:
COMBOBOX IDC_inv_type, 65, 28, 72, 35, CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_TABSTOP |ES_AUTOHSCROLL
and then tried with CBS_AUTOHSCROLL...
still, the dropdownlist has exactly the same size that i set in the resources.rc - in this case it's 35 and it's capable to hold only 2 items and the scroll does not appear.
i guess i will have to code the size myself - can't believe microsoft did not think about it.
Re: ComboBox List Drop-Down not showing?
What version of VS and SDK you are using?
Is it Win32 app or MFC based? What version of windows you are testing your app?
I wrote sample program with initial number of items set to 20, and after selecting and removing some items, I add 15 new items. Combo drop box resized accordingly, and uses a scroll bar.
The combo was inserted into a dialog and I did not make any modification.
Is it possible to post a sample app to demonstrate the problem you have?
1 Attachment(s)
Re: ComboBox List Drop-Down not showing?
Quote:
Originally Posted by
berkov
i guess i will have to code the size myself - can't believe microsoft did not think about it.
You should not guess, you should read docs instead.
Code:
COMBOBOX IDC_COMBO,65,28,72,56,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP