Question Maintaining multiple forms positioning

gchq

Well-known member
Joined
Dec 14, 2007
Messages
168
Programming Experience
10+
Launch a dialogue window from the main form, and then another dialogue window from that dialogue window. If you close the second dialogue window and call dispose the main form vanishes under any other open windows. This doesn't happen by closing a dialogue window normally, but I am attempting (rightly or wrongly) to stop memory useage creeping up by disposing of it.

So, the question is - what method can be employed to maintain the position of the windows?

Thanks
 
Form.Focus() Sigh!
Control.Focus Method (System.Windows.Forms)
help said:
Focus is a low-level method intended primarily for custom control authors. Instead, application programmers should use the Select method or the ActiveControl property for child controls, or the Activate method for forms.
Launch a dialogue window from the main form, and then another dialogue window from that dialogue window. If you close the second dialogue window and call dispose the main form vanishes under any other open windows.
I was not able to see that.
but I am attempting (rightly or wrongly) to stop memory useage creeping up by disposing of it.
??? You do have to Dispose after a ShowDialog call.
 
...or the Activate method for forms.

K. That works a treat

I was not able to see that.

I usually have some 20-30 open apps at any given time, and calling dispose on a dialogue window will, without fail, cause the main form to 'hide' behind another open window! Whilst it doesn't concern me, it could raise anxiety levels for some users

??? You do have to Dispose after a ShowDialog call.
I wonder why that is not built in then, like Form.Show()?

John - thanks again for your help and advice!
 
I usually have some 20-30 open apps at any given time, and calling dispose on a dialogue window will, without fail
I only have about 10 applications installed in my system, but I opened all of them, even some of them as multiple instances, but still I could not see this problem you describe. Though I don't see why this wouldn't happen simply with just one other active application, if the behaviour was consistent.
I wonder why that is not built in then, like Form.Show()?
Documentation explains: Form.ShowDialog Method (System.Windows.Forms)
 
Back
Top