Jesus Ramos Jesus Ramos - 1 year ago 173
C# Question

C# Windows forms cascading windows

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 would 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.

Answer Source

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

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;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download