Results 1 to 3 of 3

Thread: Running app in secondary monitor by default.

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2004
    Location
    Philippines
    Posts
    285

    Running app in secondary monitor by default.

    Hi, i have a dual monitor setup. i want my app to run in the secondary monitor by default (through settings in my app). i have been browsing the net for a solution and i found a solution which is setting the Form.Bounds to the Bounds of the secondary monitor. my problem is that if i set the bounds of my newly created form, when it gets displayed, it doesn't show in the secondary monitor.

    Code:
          private void button2_Click(object sender, EventArgs e)
          {
             Form1 frm = new Form1();
    
             frm.SetBounds(-1280, 112, frm.Bounds.Width, frm.Bounds.Height);
             MessageBox.Show(string.Format("frm.Bounds [{0},{1}]",frm.Bounds.Left,frm.Bounds.Top));
             //frm.Bounds = Screen.AllScreens[1].Bounds;
             //frm.Location = Screen.AllScreens[1].Bounds.Location;
             frm.Show();
             MessageBox.Show(string.Format("frm.Bounds [{0},{1}]", frm.Bounds.Left, frm.Bounds.Top));
             
          }

    in the code above, i first set the bounds, i can see from the message box the settings i assigned.
    after form gets displayed, i checked the bounds again, it has changed to it's default

    how do i show then a newly created form to a specific Bounds?

  2. #2
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: Running app in secondary monitor by default.

    Is there any chance whatsoever that the program will always be running on dual-screen system?

    As for a quick and dirty solution, you could use My.Settings to hold a point value (the location of the form) and set it when the program closes. When the program starts up, if has been set (meaning it was ran at least once already) you can just position the form to those coord's. Which means if you close the program on your 2nd screen then next time you run it, it'll show on the 2nd screen.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

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

    Re: Running app in secondary monitor by default.

    Have you set the form's StartPosition property to Manual?
    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

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