Jump to content

Hello there, I'm trying to figure which event to use in windows form to show the picture associated with the user selection from the combobox list (Ex: if he picks rock, upload the pic of the rock to his picturebox). Right now, when the selection of the combo box is chosen by the user, the pic doesnt change so i guess the SelectedText is not the one i need to use.

 

#pragma endregion

static int iTour = 0, iChoix1 = 0, iChoix2 = 0;

private: System::Void btnConfirm_Click(System::Object^  sender, System::EventArgs^  e) {

					if(iChoix1 == 1 && iChoix2 == 3)
					{
						lblWinner->Text = "Player 1 wins!";
					}
					else if(iChoix1 == 3 && iChoix2 == 1)
					{
						lblWinner->Text = "Player 2 wins!";
					}
					if(iChoix1 == 2 && iChoix2 == 1)
					{
						lblWinner->Text = "Player 1 wins!";
					}
					else if(iChoix1 == 1 && iChoix2 == 2)
					{
						lblWinner->Text = "Player 2 wins!";
					}
					if(iChoix1 == 3 && iChoix2 == 2)
					{
						lblWinner->Text = "Player 1 wins!";
					}
					else if(iChoix1 == 2 && iChoix2 == 3)
					{
						lblWinner->Text = "Player 2 wins!";
					}
					if(iChoix1 == 1 && iChoix2 == 1)
					{
						lblWinner->Text = "The game is a tie!";
					}
					if(iChoix1 == 1 && iChoix2 == 1)
					{
						lblWinner->Text = "The game is a tie!";
					}
					if(iChoix1 == 1 && iChoix2 == 1)
					{
						lblWinner->Text = "The game is a tie!";
					}
					else
					{
						if(iTour == 0)
						{
							picJoueur1->Image = picReset->Image;
							cboChoix->Text = "";
							iTour++;
							lblWinner->Text = "Your turn player 2!";
						}
						else
						{
							picJoueur2->Image = picReset->Image;
							cboChoix->Text = "";
							iTour++;
						}
					}


	}
private: System::Void cboChoix_SelectionChangeCommitted(System::Object^  sender, System::EventArgs^  e) {

			 if(iTour == 0)
					{
						if(cboChoix->SelectedText != "")
						{
							if(cboChoix->SelectedText == "Rock")
							{
								iChoix1 = 1;
								picJoueur1->Image = picRock->Image;
							}
							else if(cboChoix->SelectedText == "Paper")
							{
								iChoix1 = 2;
								picJoueur1->Image = picPaper->Image;
							}
							else if(cboChoix->SelectedText == "Scissors")
							{		
								iChoix1 = 3;
								picJoueur1->Image = picScissors->Image;
							}
						}
					}
					else if(iTour == 1)
					{
						if(cboChoix->SelectedText != "")
						{
							if(cboChoix->SelectedText == "Rock")
							{
								iChoix2 = 1;
								picJoueur2->Image = picRock->Image;
							}
							else if(cboChoix->SelectedText == "Paper")
							{
								iChoix2 = 2;
								picJoueur2->Image = picPaper->Image;
							}
							else if(cboChoix->SelectedText == "Scissors")
							{		
								iChoix2 = 3;
								picJoueur2->Image = picScissors->Image;
							}
						}
					}

		 }
};
}

 

CPU: Intel Core i9-10900K  MOBO: ROG MAXIMUS XII FORMULA GPU: 2080ti Hall of Fame 10th anniversary limited edition  PSU: Asus ROG THOR 1200W  COOLER: Optimus foundation black acetal RADS: 3x EKWB CoolStream PE 360  LOOP: EKWB torque HDC fittings / EKWB ZMT 15,9/9,5mm / EKWB CryoFuel Clear MONITOR: Acer predator X34

Link to comment
https://linustechtips.com/topic/775575-combobox-event/
Share on other sites

Link to post
Share on other sites

SelectedIndexChanged I think is what you're looking for. 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
https://linustechtips.com/topic/775575-combobox-event/#findComment-9784205
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×