954,504 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

CLR Windows Form Application C++ Work

So basically, I'm making a Windows Form Application CLR which calculates a worker's wage. Problem is, when I select the schedule (day,night,afternoon,mixed), I use a button for each schedule respectively, which, upon click, calculates everything on the data you've input. While this is effective, I am being asked to use a combo box to demonstrate each schedule, and a single "Calculate" button for this, yet I do not know how to use a combo box correctly, nor how to use the selected option (say, I selected night, and do the respective calculation parameters). I am unable to find a tutorial which might help me, so would anyone mind telling me how do I use the items in the combo box, which would later influence in the calculation? (i.e. if I select 'day', I get 1.5 over my wage for each extra hour, while if my schedule is 'night', it's 2 over my wage).

Raim
Newbie Poster
20 posts since Jun 2011
Reputation Points: 10
Solved Threads: 0
 

You have already stated the items in the combo box -- Day, Afternoon, Night and Mixed. Do you know how to add those items to the combo box while in Form Designor? (In the comboBox Properties page scroll down to the Items Collection and you can add them there. See thumbnail below)

In the Calculate button's SelectedIndexChanged event handler

private: System::Void comboBox1_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
			if( this->comboBox1->Text == "Day" )
			{
					 // do calculations for Day here
			}
			else if(this->comboBox1->Text == "Afternoon" )
			{
					 // do calculations for Afternoon here
			}
			else if(this->comboBox1->Text == "Night" )
			{
					 // do calculations for Night here
			}
			else 
			{
					 // do calculations for Mixed here
			}

	}
Attachments Untitled.jpg 140.48KB
Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

That is indeed awesome, solved my problem. Thanks. Just before this goes into the abyss, is there a way to select something on the combo box and do the calculations when you click a button? It wouldn let me work a bit more, but thanks again.

Raim
Newbie Poster
20 posts since Jun 2011
Reputation Points: 10
Solved Threads: 0
 

Yes, that is exactly the code I posted.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: