Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我目前有一个菜单按钮,允许用户打开一个新对话框,我希望将其直接放置在主窗体的右侧。用户可以根据需要打开任意数量的这些对话框,但我希望它们层叠在他们打开的第一个对话框之上(如果有的话)。我已经看到了使用 MdiLayout 执行类似操作的方法,但这仅适用于普通对话框。
你想遍历所有打开的对话框,设置每个窗口的位置吗?
this.Location = new Point(x,y);
或者
int prevHeight =0; foreach (Form f in this.OwnedForms) { x += 5; y += prevHeight; f.Location = new Point(x, y); prevHeight += f.Height; }