Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Combobox display issue Visual Studio 2010 C++

Combobox display issue Visual Studio 2010 C++

Combobox display issue Visual Studio 2010 C++

I am not new to programming but am new to Visual Studio and am having problems doing the most basic of things, and for two days I have search for the answer with no success.

Here's what I'm doing:

Visual Studio 2010 usual Visual C++
Windows Forms

I have designed my form and most things work well but I am having trouble with combobox. Here is my code:

private: System::Void comboBox1_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
            comboBox1->Items->Add("US $");
            comboBox1->Items->Add("British Pound");
            comboBox1->Items->Add("Australian $");
            comboBox1->Items->Add("Canadian $");
            comboBox1->Items->Add("Swiss Franc");


What I'm trying to achieve is when a user selects one of the options it then updates a label 'ticker' with the appropriate symbol, ie GLD for Gold, and I would like to do this in the 'ticker' object using a switch statement but not only can I not find the correct syntax but my combobox has no values in it, the program compiles with no errors so I am really confused.

I can display them using the 'Items / collections' tool in its properties but then I can't manipulate the data.

If anyone has a solution or a better method in which to achieve this pleas elet me know as I have no more hair to pull out !

Thank you,

RE: Combobox display issue Visual Studio 2010 C++

This looks more like C# than C++, but in either case are you adding the values to the combobox at design time?

If not, then your combobox will not contain any items until you change the selection of the combobox, which you can't do until you have items to select from.....

Somewhere, you have to have a form initialization function, for example in MFC you might use OnInitDialog in a dialog based application in which you would execute all the comboBox1->Items->Add statements.

Once the control is initialized, then your SelectedIndexChanged function would allow you to fined the value of the selected index in order to update the "ticker".

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close