ComboBox List Drop-Down not showing?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 19

Thread: ComboBox List Drop-Down not showing?

  1. #1
    Join Date
    Feb 2004
    Location
    Texas, USA
    Posts
    1,206

    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!

  2. #2
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,062

    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.

  3. #3
    Join Date
    Mar 2004
    Location
    (Upper-) Austria
    Posts
    2,899

    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.
    I am not offering technical guidiance via email or IM
    Come on share your photo with us! CG members photo album!
    Use the Code Tags!

  4. #4
    Join Date
    May 1999
    Location
    DELAWARE, USA
    Posts
    9,915

    Re: ComboBox List Drop-Down not showing?

    If you create combo dynamically, set rectangle width (top, bottom) to desire drop list height.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  5. #5
    Join Date
    Apr 2013
    Location
    Prague / Cracow
    Posts
    47

    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
    .

  6. #6
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,974

    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.
    Best regards,
    Igor

  7. #7
    Join Date
    Apr 2013
    Location
    Prague / Cracow
    Posts
    47

    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.

  8. #8
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,392

    Re: ComboBox List Drop-Down not showing?

    Quote Originally Posted by berkov View Post
    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.
    Victor Nijegorodov

  9. #9
    Join Date
    Apr 2013
    Location
    Prague / Cracow
    Posts
    47

    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! :-)

  10. #10
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,392

    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...
    Victor Nijegorodov

  11. #11
    Join Date
    Apr 2013
    Location
    Prague / Cracow
    Posts
    47

    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

  12. #12
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,974

    Re: ComboBox List Drop-Down not showing?

    Quote Originally Posted by berkov View Post
    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 View Post
    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.
    Best regards,
    Igor

  13. #13
    Join Date
    Apr 2013
    Location
    Prague / Cracow
    Posts
    47

    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.

  14. #14
    Join Date
    May 1999
    Location
    DELAWARE, USA
    Posts
    9,915

    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?
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  15. #15
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,974

    Re: ComboBox List Drop-Down not showing?

    Quote Originally Posted by berkov View Post
    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
    Attached Files Attached Files
    Last edited by Igor Vartanov; April 25th, 2013 at 02:26 AM.
    Best regards,
    Igor

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center