Nov 19th, 2002, 07:08 AM
#1
Thread Starter
Lively Member
Center a Form inside MDI
Hi All,
I am not able to center any child form inside the main MDI form, even with the use of the "StartPosition" in design properties.
Any idea?
Thanks for any help...
<><><><><><><><><><><><><><><><><><>
<><> REMEMBER,,,,KNOWLEDGE IS POWER <><>
<><><><><><><><><><><><><><><><><><>
Nov 19th, 2002, 08:44 AM
#2
New Member
Might try to position the form like so:
VB Code:
Form1.Left = MDIForm1.Width / 2 - Form1.Width / 2
Have you been sure to access the mdiForm's left property instead of the childForm's left property?
Make sure to put that code in the Form1_Load event, AND the mdiForm1.resize event. Wouldn't put it anywhere else unless you want to annoy people who want to move the form
I have attached the code and the form. Don't forget to reply to this thread if it works (or even email me for that matter)
Attached Files
Last edited by NomadtheGrey; Nov 19th, 2002 at 08:55 AM .
Nov 19th, 2002, 12:25 PM
#3
Sleep mode
the above code will never works in VB.NET.
If you want to do that in VB.NET then scroll down to the last post written by Me (Pirate )
here is the link
http://www.vbforums.com/showthread.p...hreadid=213750
Nov 19th, 2002, 04:29 PM
#4
Thread Starter
Lively Member
Hi NomadtheGrey,
Pirate, is correct. the code you sent me is for vb6 and will not work on vb.net.
Pirate, I checked your code ... wonderful ..
Thank you for both of you.
<><><><><><><><><><><><><><><><><><>
<><> REMEMBER,,,,KNOWLEDGE IS POWER <><>
<><><><><><><><><><><><><><><><><><>
Nov 19th, 2002, 04:41 PM
#5
Sleep mode
the code and zip file sent by NomadtheGrey is VB6 , the one I sent is VB.NET.
did you figure things out of that ??
Last edited by Pirate; Nov 19th, 2002 at 04:44 PM .
Nov 19th, 2002, 04:53 PM
#6
Thread Starter
Lively Member
Yes Pirate, this is exactly what I need, thanks a lot.
Movint to VB.NET is not easy, I was feeling good in vb6 days
Pirate can you do me another favore please
I posted a question titled "Database Note Updated !", can you help me out in that please.
ADSC
<><><><><><><><><><><><><><><><><><>
<><> REMEMBER,,,,KNOWLEDGE IS POWER <><>
<><><><><><><><><><><><><><><><><><>
Nov 19th, 2002, 04:57 PM
#7
Sleep mode
umm , can I have a look at your project so far. Promise you to give it a shot
send the project with db now ??
Nov 19th, 2002, 05:54 PM
#8
Thread Starter
Lively Member
I can't send you the db because I am using MSDE not Access,
I'll send you a small application having the same steps I am doing the the db project, okey??
Attached Files
<><><><><><><><><><><><><><><><><><>
<><> REMEMBER,,,,KNOWLEDGE IS POWER <><>
<><><><><><><><><><><><><><><><><><>
Nov 19th, 2002, 06:14 PM
#9
Sleep mode
i guess i can't work without the present of DB. you need to send the db as well , or am i wrong??
Nov 19th, 2002, 06:20 PM
#10
Thread Starter
Lively Member
Fine, if you have MSDE I'll send you the database name, table name & structure .. I think this is it all.
<><><><><><><><><><><><><><><><><><>
<><> REMEMBER,,,,KNOWLEDGE IS POWER <><>
<><><><><><><><><><><><><><><><><><>
Nov 19th, 2002, 06:24 PM
#11
Sleep mode
unfortunately I don't have . ,
maybe others can help you to get out of this hell.bye
Nov 19th, 2002, 06:49 PM
#12
Thread Starter
Lively Member
Ok, thanks for your help and your time.
<><><><><><><><><><><><><><><><><><>
<><> REMEMBER,,,,KNOWLEDGE IS POWER <><>
<><><><><><><><><><><><><><><><><><>
Nov 19th, 2002, 07:01 PM
#13
Nov 19th, 2002, 11:29 PM
#14
Addicted Member
Centering form
I think this is helpful for u
'Centering the form
Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 4
Nov 20th, 2002, 07:59 AM
#15
New Member
I apologize for sending VB6 material on a vb.NET forum. I wasn't paying close enough attention to what I was doing.
However, you can open the project in .NET anyway, which will translate it into pseudo-equivalent code. The only exception with this particular project was with the statement
.NET doesn't support it, because .NET doesn't need it. I commented it out, and the altered code was identical in function, if different in appearance. It went like so:
VB Code:
Form1.DefInstance.Show()
Form1.DefInstance.Left = VB6.TwipsToPixelsX(VB6.PixelsToTwipsX(MDIForm1.DefInstance.Width) / 2 - VB6.PixelsToTwipsX(Form1.DefInstance.Width) / 2)
Of course, such strange translation is hardly necessary. I wrote much more concise code as follows, using .NET:
VB Code:
dim mdiChild as new Form2()
mdiChild.mdiParent = Me
mdiChild.Show()
mdiChild.Anchor = AnchorStyles.None
mdiChild.Left = Me.Width /2 - mdiChild.width /2
Nov 20th, 2002, 03:26 PM
#16
Thread Starter
Lively Member
RESOLVED
Thanks NomadtheGrey..
I got the idea from Pirate's code, I was missing one thing ... to subtract the docking size, then it'll be okey...
Thanks again....
ADSC
Last edited by adsc; Nov 20th, 2002 at 10:14 PM .
<><><><><><><><><><><><><><><><><><>
<><> REMEMBER,,,,KNOWLEDGE IS POWER <><>
<><><><><><><><><><><><><><><><><><>
Nov 20th, 2002, 10:01 PM
#17
New Member
Don't forget to put RESOLVED in the subject line now.
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width