I need to copy an EventHandler assigned to one resource,
to another (runtime generated) resource.
Here is the code I used :
public void test(object xi_sender)
{
System.Windows.Forms.Menu parent = (xi_sender as
System.Windows.Forms.MenuItem).Parent;
System.Windows.Forms.Label button;
for (int index = 1; index < parent.MenuItems.Count;
index++)
{
button = new System.Windows.Forms.Label();
button.Click += parent.MenuItems[index].Click;
}
}
But it will not compile. The error message is as follows :
.... (10): The event 'System.Windows.Forms.MenuItem.Click'
can only appear on the left hand side of += or -=
How can I acomplish this task ?
Thank you,
Yoav
|