CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  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
    Apr 2004
    Posts
    102

    Re: Combo Box Selection Value

    Try...

    Code:
    int i = cmb->SelectedIndex;
    string equivalent would be...

    Code:
    cmb->SelectedIndex.ToString();

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