[Solved] Dynamically added event handler? [closed]


You DO know on which form b1 is by casting the sender

void b1_click(object sender, EventArgs e)
{
    if (sender is Button)
    {
        var b1 = (Button) sender;
        b1.Parent.Controls.RemoveByKey(b1.Name);
        No1(b1.TopLevelControl, b1.Location.X, b1.Location.Y);
    }                   
}

The property TopLevelControl gives you the Form and Parent gives you the ControlContainer (can be the Form but also a Panel)

solved Dynamically added event handler? [closed]