Results 1 to 6 of 6

Thread: [RESOLVED] Move form to other monitor?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Location
    England
    Posts
    283

    Resolved [RESOLVED] Move form to other monitor?

    I have a dual monitor set up, and for the prgrams i create it would be really handy to add a function that moves the form to the other monitor, when a button is clicked for example.

    How could this b done??

    Thanks

    GTJ

  2. #2
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Re: Move form to other monitor?

    By making it appear at a higher Left value than the top of the first resolution.

    For example.

    If you had 2 monitors at 1024x768, set the form to appear at Left value of 1025. Thus putting it on the other monitor.
    Zeegnahtuer?

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Location
    England
    Posts
    283

    Re: Move form to other monitor?

    ahhh i c

    cheers!!

    GTJ

  4. #4
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Re: [RESOLVED] Move form to other monitor?

    Glad it works for you
    Zeegnahtuer?

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [RESOLVED] Move form to other monitor?

    You can use the Screen class to get information about your monitors. The following code will put a form in the top, left corner of the second monitor if there is more than one, or else the top, left corner of the first monitor if there is only one:
    Code:
    Screen[] screens = Screen.AllScreens;
    Screen targetScreen = null;
    
    if (screens.Length == 1)
    {
        // There is only one monitor.
        targetScreen = Screen.PrimaryScreen;
    }
    else
    {
        // There are multiple monitors.
        foreach (Screen scr in screens)
        {
            if (!scr.Primary)
            {
                // This is not the primary monitor.
                targetScreen = scr;
                break;
            }
        }
    }
    
    this.Location = targetScreen.Bounds.Location;
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Location
    England
    Posts
    283

    Re: [RESOLVED] Move form to other monitor?

    wow thats cool,

    cheers

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