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

    Combo Box Selection Value

    Is there a way to read the current value of a combo box.

    I tried using i = (int)cmb -> SelectedValue; but it is giving me a runtime error.

    Example:
    Lets say I have a combo box with 5 items. they are a list of numbers spelled out. When one of them is selected, say Three, I want an int to be assigned the current value that is selected. Since Three is the 3rd item in the list then the int variable should be 3, or 2 if the first item is treated as value 0.

  2. #2
    Join Date
    Jul 2002
    Posts
    2,543

    Re: Combo Box Selection Value

    Use GetCurSel function.

  3. #3
    Join Date
    Nov 2009
    Posts
    29

    Re: Combo Box Selection Value

    Sorry, but I am not sure what that is and how to use it. I tried some googling, but what ever I try is not working.

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

    Re: Combo Box Selection Value

    Victor Nijegorodov

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

    Re: Combo Box Selection Value

    Quote Originally Posted by KazoWAR View Post
    Sorry, but I am not sure what that is and how to use it. I tried some googling, but what ever I try is not working.
    Didn't seem that hard to me. Always check MSDN first.

    Google

  6. #6
    Join Date
    Nov 2009
    Posts
    29

    Re: Combo Box Selection Value

    'System::Windows::Forms::ComboBox'

    That is what its using, I am using the designer, that is the only combo box listed, I found CComboBox::GetCurSel, but it doesn't work for ComboBox.

    'GetCurSel' : is not a member of 'System::Windows::Forms::ComboBox'

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

    Re: Combo Box Selection Value

    Quote Originally Posted by KazoWAR View Post
    'System::Windows::Forms::ComboBox'

    That is what its using, I am using the designer, that is the only combo box listed, I found CComboBox::GetCurSel, but it doesn't work for ComboBox.

    'GetCurSel' : is not a member of 'System::Windows::Forms::ComboBox'
    You're using .net, which is off topic in this forum. Try the managed C++ forum.

  8. #8
    Join Date
    Nov 2009
    Posts
    29

    Re: Combo Box Selection Value

    Quote Originally Posted by GCDEF View Post
    You're using .net, which is off topic in this forum. Try the managed C++ forum.
    Oh sorry, Since I am using Visual C++ I though this was the best place.

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