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);
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *