CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Posts
    8

    How to create ComboBox dynamically???

    Hi,

    I try to create a CComboBox dynamically without using the ressource editeur like this:

    r2.bottom = 30;
    r2.left = 10;
    r2.right = 150;
    r2.top = 10;
    pNewComboBox = new CMyComboBox;
    pNewComboBox->Create(WS_VISIBLE|CBS_DROPDOWNLIST,r,AfxGetMainWnd(),5003);
    pNewComboBox->AddString("A");
    pNewComboBox->AddString("B");
    pNewComboBox->AddString("C");

    But at runtime, I try to see the list(A,B,C), it doesn't work,
    I can't see the list because the dropdown list is the same size
    than the ComboBox. How can I set the size of dropdowm list?
    or How can i set the combobox correctely?

    Thanks


  2. #2
    Join Date
    May 1999
    Location
    Germany
    Posts
    106

    Re: How to create ComboBox dynamically???

    Hi,

    the rectangle you pass to the Create-function specifies the size of dropdown list. If you want to set the combobox size use the member-function SetItemHeight of CComboBox.

    For example
    pNewComboBox->SetItemHeight(-1,15);
    sets the height of the closed combobox.

    Hope i gave you the needed informations.
    Good Luck!

    Peter

    P.S.: You initialized a variable called r2. But in function call you called it r.



Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured