0

我继承了很多代码,但遇到以下问题:当主表单移动时,让位于“主表单”上特定位置的表单移动。

现在,我有一个列表,其中存储了将位于我的表单中的每个表单,以及 masterForm.ResizeEnd 的事件处理程序。在事件处理程序中,我尝试遍历列表并将 .location 属性设置为 masterForm.location+constant。但这不起作用。我尝试了各种各样的东西,但没有一个奏效。

代码:

public List<Form> openForms=new List<Form>(1);

private void addForm(Form argument)
{
    openForms.Add(argument);
}

private void masterForm_ResizeEnd(object sender, System.EventArgs e)
{
    for(int i=0; i<openForms.Count; i++) 
        openForms[i].Location = new system.drawing.point(this.location.x+constant, this.location.y+constant);
}
4

1 回答 1

0

它应该可以工作,我认为您的代码没有明显错误。尝试设置位置

openForms[i].Invoke((MethodInvoker)delegate{openForms[I].Location = new system.drawing.point(this.location.x+constant, this.location.y+constant);});
于 2013-05-31T06:07:47.783 回答