开发者

C# Windows forms cascading windows

开发者 https://www.devze.com 2023-04-07 04:22 出处:网络
I currently have a menu button that allows users to open a new dialog which I would like to be placed directly to the right of the main form. The user can open as many of these dialogs as they w开发者

I currently have a menu button that allows users to open a new dialog which I would like to be placed directly to the right of the main form. The user can open as many of these dialogs as they w开发者_StackOverflow中文版ould like but I would like them to cascade on top of the first dialog that they opened (if there is one). I've seen ways to do something similar using an MdiLayout but this is just for normal dialogs.


Do you want to loop through all the open dialogs, setting each windows location?

this.Location = new Point(x,y);

or

int prevHeight =0;
foreach (Form f in this.OwnedForms)
{
x += 5;
y += prevHeight;
f.Location = new Point(x, y);
prevHeight += f.Height;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消