I have this code:
public void setPanelHalfHorizontalScreen(Panel p)
{
if (p != null)
{
p.Width = Screen.PrimaryScreen.Bounds.Width / 2 - 2;
this.panelsForHalfScreen.Add(p.Name, p);
// http://stackoverflow.com/questions/2261828/does-an-event-gets-executed-twice-if-callback-was-assigned-twice-to-the-object
this.form.Resize -= new EventHandler(form_Resize); // error raised on this line: ArgumentException was unhandled
this.form.Resize += new EventHandler(form_Resize);
}
}
void form_Resize(object sender, EventArgs e)
{
foreach (DictionaryEntry p in panelsForHalfScreen)
{
this.setPanelHalfHorizontalScreen((Panel)p.Value);
}
}
How can I fix it?
EDIT