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.
Asked
Active
Viewed 2,115 times
1 Answers
2
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;
}

Jeremy Thompson
- 61,933
- 36
- 195
- 321
-
The thing is that that makes them open directly on top of each other, I want it so that the first one opens at a location I specify and all others will show up slightly down and to the right of that specific one like the normal windows behavior. – Jesus Ramos Sep 26 '11 at 01:54
-
I was trying to see if there's a non hackish way of doing this since I wrote this (saving the last open window so i dont have to iterate) and doing the increments. Windows has support for Mdi cascaded and normal cascade of the main form but i just dont see it for spawned forms with custom location – Jesus Ramos Sep 26 '11 at 03:46
-
This ended up being the right way, I talked to a guy who's been doing this for a while and he says only MdiLayout's support cascading on specific windows. Thanks – Jesus Ramos Sep 26 '11 at 23:38