Results 1 to 7 of 7

Thread: Centre the Form

  1. #1

    Thread Starter
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961

    Question Centre the Form

    When I am displyaing my MDIChild form, i want to display it at centre of the screen. At design time, setting windowstate for MDIChild form is not allowed.

    Pls guide me how to do it at runtime

    regards,

    prakash

  2. #2
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172
    you can try something like this (doing it by head)



    VB Code:
    1. mdichild.left = (me.width /2) - (mdichild.width / 2)
    2. mdichild.top = (me.height /2) - (mdichild.height /2)


    something like that...first get the center of the form containing the child itself.. then set it more left by getting the size of half the child :S.....

    though i dont think this is the best way to do it :S
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

  3. #3

    Thread Starter
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961
    i used to do the same thing in vb 6.0. but i dont think this is supported in .net environment. well, let me try.

    is there anything that i can do with...

    VB Code:
    1. TwipsToPixelsX
    2. TwipsToPixelsY
    3. PixelsToTwipsX
    4. PixelsToTwipsY


    ????

  4. #4
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172
    i think it should work...

    though i am pretty sure Twips are removed from vb.net everything is calculated in Pixels now... and for the best.. i hated twips :P
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

  5. #5
    Addicted Member Hole-In-One's Avatar
    Join Date
    Mar 2003
    Location
    Minnesota
    Posts
    195
    Just set the startup position to "center parent" or "center screen" at design time.

  6. #6

    Thread Starter
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961
    if its that easy, i would have never posted the query

  7. #7
    Addicted Member Hole-In-One's Avatar
    Join Date
    Mar 2003
    Location
    Minnesota
    Posts
    195
    so did or didnt that work?


    It works for me!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width