lidds Posted December 2, 2004 Posted December 2, 2004 I'm trying to figure out how to position a MDI form (frmChild) in the centre of it's parent form (frmMain). Could anyone please provide me with some sample code if possible in vb.net. Cheers Simon Quote
Administrators PlausiblyDamp Posted December 2, 2004 Administrators Posted December 2, 2004 http://www.xtremedotnettalk.com/showthread.php?t=81137&highlight=MDI%2A is probably worth a look. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
AlexCode Posted December 3, 2004 Posted December 3, 2004 I believe you only have to set the startposition property of the child form to CenterScreen. If it's not CenterScreen it's CenterParent... :eek: Alex :p Quote Software bugs are impossible to detect by anybody except the end user.
psyphen Posted September 2, 2005 Posted September 2, 2005 I came across this posting after searching for "positioning mdi" in Google because I couldn't figure out how to position an MDI child form, so forgive me if I'm taking over this thread for this purpose. Just wanting to help anyone else who is trying to figure this out on their own and might have come across this thread. Okay. Generally speaking, you might have been trying to use the child form's .Left, .Top, or .Location properties in an attempt to position the form. However, as you would have seen by now, this doesn't appear to work. When following the link kindly provided by PlausiblyDamp you would have noticed some VB code written by dynamic_sysop which uses a cast to the .MdiParent property of the child form before setting the form's location. I've confirmed that this works, but if you're using C# (as I am), then similar code is as follows (assuming you're placing this code in the _Load method of the MDI child form, the child form has already been shown, and your MDI parent form is named "MDIParent"): this.MdiParent = (MDIParent)this.MdiParent; this.Location = new Point(300, 300); Of course, follow good programming practice and use variables instead of hard-coded values, but at least you should get the idea. Quote
AlexCode Posted September 2, 2005 Posted September 2, 2005 "Generally speaking, you might have been trying to use the child form's .Left, .Top, or .Location properties in an attempt to position the form. However, as you would have seen by now, this doesn't appear to work." It works... you just have to set the StartPosition of the child form to Manual... Alex :p Quote Software bugs are impossible to detect by anybody except the end user.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.