1
我有这样的代码:在事件委托上使用 - =时,System.ArgumentException未处理?
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);
}
}
我怎样才能解决这个问题?
编辑 alt text http://img519.imageshack.us/img519/3352/bb4u.jpg
检查我加 – Pentium10
图像是否有任何异常的详细?像消息或堆栈跟踪 – limpalex
是的,form_resize调用 - > setPanelHalfHorizontalScreen - >发生异常 – Pentium10