CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Threaded View

  1. #1
    Join Date
    Apr 2009
    Posts
    18

    Problems with the event handler

    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);


    tp.Controls.Add(button);
    parentglobalobj = parentobj;
    button.Click += new EventHandler(handler1);
    return true;
    }

    public void handler1(object sender, EventArgs e)
    {
    // tp.text takes the last tabpage name n not the tabpage from where the respective button was created
    test.addform(parentglobalobj, tp.text);
    }
    Last edited by nightscorpion; April 29th, 2009 at 04:03 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured