/*_______________________________________________________________ * E V E N T H A N D L E R F O R M U L T I P L E C O N T R O L S * C++ Version * Ron Kessler * ______________________________________________________________ */ //***********START OF MY CODE*************** /*--handle all click events from one handler. Notice it is not obvious! Create a new click event handler * for the first radiobutton. Rename the handler. Set the click event for * all the buttons in the methods page (F4 then lightning bolt). Select this handler for all the * click events for each control. Look in the generated code of this form to see the code for each * button. It points to this handler when any of the buttons is clicked. */ private: System::Void RadioButton_Click(System::Object^ sender, System::EventArgs^ e) { //---use sender to find out which button was clicked! RadioButton^ whichButton = safe_cast(sender); //create a reference variable of radiobutton type if(whichButton->Name == "rdoYes") MessageBox::Show("You picked Yes", "Voting results", MessageBoxButtons::OK, MessageBoxIcon::Information); else if (whichButton->Name =="rdoNo") MessageBox::Show("You picked No", "Voting results", MessageBoxButtons::OK, MessageBoxIcon::Information); else if (whichButton->Name =="rdoNotSure") MessageBox::Show("You picked Not sure", "Voting results", MessageBoxButtons::OK, MessageBoxIcon::Information); } private: System::Void btnQuit_Click(System::Object^ sender, System::EventArgs^ e) { this->Close(); } }; }