In the program I have multiple panels being created with picture boxes. The picture boxes are delegated to be clickable. I would like to have the user to have the option to remove one of the panels/picture boxes from the order. Right now if it is removed and the order is rearranged all picture boxes after the one that was removed retains its delegated order. So clicking on any of them after the one that was removed, skips to the one next to it down the line (ie click on #9 and it will go to #10). I need to remove the delegation of the reordered ones and re delegate them correctly. I have tried:
int z2 = z;
var myClickDelegate = (EventHandler)delegate { clicked(z2, null); };
PicBx[z].Click += myClickDelegate;
to create and
PicBx[z].Click -= myClickDelegate;
to remove
and also
int z2 = z;
PicBx[z].Click -= delegate { clicked(z2, null); };
but both of them does not remove the origional delegation.