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

    Post regarding simple usage of combo box

    i have made a combo box in one of my dialog boxes using drag & drop controls
    now I wish to add a default drop down menu in it.........how can i do so??please tel a descriptive one went through many books and forums but could not find one suitable..............

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: regarding simple usage of combo box

    You can add data in the resource editor. How you do it depends which version of C++ you're running.

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: regarding simple usage of combo box

    What is "a default drop down menu" in a combobox?
    Or you meant filling in the combobox with the items?
    If latter then:
    1. add control member variable for this combobox, say c_MyCombo
    2. use CComboBox::AddString method to add items
    3. you can place such a code in your dialog OnInitDialog method like:
      Code:
      CSomeDialog::OnInitDialog()
      	CDialog::OnInitDialog();
      	
      	c_MyCombo.AdddString(_T("Item 1"));
      	c_MyCombo.AdddString(_T("Item 2"));
      	c_MyCombo.AdddString(_T("Item 3"));
      	...
      }
    {
    Victor Nijegorodov

  4. #4
    Join Date
    May 2009
    Posts
    88

    Re: regarding simple usage of combo box

    then how can i use the value selected by the user??

  5. #5
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: regarding simple usage of combo box

    Quote Originally Posted by pinnachio View Post
    then how can i use the value selected by the user??
    Have you tried reading the documentation in MSDN?

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: regarding simple usage of combo box

    CComboBox::GetCurSel
    CComboBox::GetLBText
    Code:
    CString strText;
    int ind = c_Combo.GetCurSel();
    if(ind != CB_ERR)
    	c_Combo.GetLBText(ind, strText);
    Victor Nijegorodov

  7. #7
    Join Date
    May 2009
    Posts
    88

    Re: regarding simple usage of combo box

    thnx a lot.......

Tags for this Thread

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