Instead of using 32 forms for one button I wanted to ask if it were possible that I could have 32 different message boxes stored on a single button in form 2 and the messagebox that comes up is purely down to one of the 32 buttons the user clicked on form1. Because I have a textbox and another button on form2 im not using the if and switch statements because I want the user to see form2.
For example: there's a map of a city on form 1 and each town has a button. there are 32 towns and I'd like the "info" button on form2 to open up the messagebox associated with the town the user clicked on in form1
I would appreciate all the help I can get as you might make me a rich man someday hehehe.
Loading
Sukesh MarlaPosted Oct 2, 2012, 3:11 PM
VulpesPosted Oct 2, 2012, 10:50 AM
Million AirePosted Oct 2, 2012, 10:35 AM
Sukesh MarlaPosted Sep 30, 2012, 2:02 PM
Button1.Tag="Country1";
Button2.Tag="Country2";
.
.
NOw add Same Event Handler for all buttob
Button1.Click+=new EventHandler(Button_Click);
Button2.Click+=new EventHandler(Button_Click);
Button3.Click+=new EventHandler(Button_Click);
.
.
protected void Button_Click(Object sender, EventArgs e)
{
Button b=sender as Button;
MessgaeBox.Show(b.Tag.ToString());
}
Check this is correct answer if it helped.