An example using a single event triggered by multiple combo boxes

	//Setting up combo boxes
	MyComboBox1->SelectedIndexChanged += gcnew System::EventHandler(this, &frmMain::GeneralComboBox_SelectedIndexChanged);
	MyComboBox1->Tag = 1;		//In this example we use the tag property to store an ID we will use later
	MyComboBox2->SelectedIndexChanged += gcnew System::EventHandler(this, &frmMain::GeneralComboBox_SelectedIndexChanged);
	MyComboBox2->Tag = 2;
	MyComboBox3->SelectedIndexChanged += gcnew System::EventHandler(this, &frmMain::GeneralComboBox_SelectedIndexChanged);
	MyComboBox3->Tag = 3;

	//Determining which combo box triggered the event
	private: System::Void GeneralComboBox_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e)
		int TagIndexValue;
		System::Windows::Forms::ComboBox ^CallingComboBox = safe_cast<system::windows::forms::combobox^>(sender);
		TagIndexValue = Convert::ToInt32(CallingComboBox->Tag);
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.


Your email address will not be published.