Hello everyone,
i am having problems in passing arguments to the event handler which i am trying from the past 2 days and not able to solve it.
my code looks like this below. I try to Create a button for the tabpages dynamically.Lets say we have 4 tabpages and i have created 4 buttons for each of these tabpages. When i click on the button of the 2nd tab page i would like to send the name of the this tabpage to my event handler in order to send it as an argument for the method(addform) that i call in the event handler..however tp.text takes always the last tabpage name in the event handler and not the 2nd tabpage.
would be gratefull for any help
thank u
public bool CreateButton(TabPage tp, Object parentobj)
{
Button button = new Button();
button.Location = new System.Drawing.Point(250,440);
globalTabname= tp.Text;
tp.Controls.Add(button);
parentglobalobj = parentobj;
button.Click += new EventHandler(handler1);
return true;
}
public void handler1(object sender, EventArgs e)
{
// i need to also get the tp.text to send it as an argument to the method addform
test.addform(parentglobalobj);
}