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...
Printable View
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...
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)
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:p)
here is the link
http://www.vbforums.com/showthread.p...hreadid=213750
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.
the code and zip file sent by NomadtheGrey is VB6 , the one I sent is VB.NET.
did you figure things out of that ??;)
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
umm , can I have a look at your project so far. Promise you to give it a shot ;)
send the project with db now ??
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??
i guess i can't work without the present of DB. you need to send the db as well , or am i wrong??
Fine, if you have MSDE I'll send you the database name, table name & structure .. I think this is it all.
unfortunately I don't have .:( ,
maybe others can help you to get out of this hell.bye
Ok, thanks for your help and your time.
any time;)
I think this is helpful for u
'Centering the form
Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 4
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
VB Code:
load Form1 Form1.show
.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
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
Don't forget to put RESOLVED in the subject line now.