Results 1 to 6 of 6

Thread: Form moving

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Posts
    14

    Form moving

    I know this is horridly easy. Trying to load a form when I click a button. Got that far. The new form comes up in an inconvient spot on my desktop, so I would like to open it and then immediately move it to the upper right of my screen. Question is, how?

    Jeff

  2. #2
    Frenzied Member MaximilianMayrhofer's Avatar
    Join Date
    Aug 2007
    Location
    IM IN YR LOOP
    Posts
    2,001

    Re: Form moving

    Code:
    Dim frm As New Form1() With { .Location = New Point(My.Computer.Screen.WorkingArea.Width - Me.Width, 0) }
    frm.Show()
    But you'll have to set the form's location mode to Manual in the designer for this to work.

  3. #3
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Form moving

    vb Code:
    1. FormX.Location = New Point(0,0)
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  4. #4

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Posts
    14

    Re: Form moving

    A little too new for that. I assume 'FormX' is replaced with the current form that I want moved? Also, does this go in the first form or the second? I click a button to bring up a new form(window).

    Thanks.

  5. #5

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Posts
    14

    Re: Form moving

    whew, okay, got to semi-work. This will put it at the top left. I need this at the top right. My desktop is 1920x1200. I assume that 0,0 is the coordinates that the upper left window will be placed at. So 1920 minus my window width should do it, if my assumptions are right. How do I find out my window width?

  6. #6
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Form moving

    Yes, that's right... FormX is the form that needs to be moved. In case it is the current form you can use the Me keyword too.

    To position it to the top right corner, you can use this:
    vb.net Code:
    1. Me.Location = New Point(SystemInformation.WorkingArea.Width - Me.Width, 0)
    Last edited by Pradeep1210; Mar 7th, 2009 at 12:59 PM.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

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