开发者

Visual Studio Debug - Window start screen

Is there a way to tell Visual Studio 2010 to start a Windows Form Application (while debugging) on partic开发者_如何学Goular screen.


Or you could try this. Note that there is no error checking for what happens if no secondary screen is connected.

using System;
using System.Windows.Forms;

namespace ScreenPositioning
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            #if DEBUG
            var screen = Screen.AllScreens;
            foreach (var s in screen)
            {
                if (!s.Primary)
                {
                    this.Bounds = s.Bounds;
                    this.WindowState = FormWindowState.Maximized;
                }
            }
            #endif
        }
    }
}


Update: I 'm making some assumptions here:

  1. That by "while debugging" you mean "when the VS debugger is going to be attached to the process", not "when running a debug build"
  2. That by "particular screen" you mean "particular piece of application UI", not "particular computer monitor" (I hadn't even considered that before I saw Mikael Östberg's answer)

Answer:

Not automatically. You will have to arrange for this with code, i.e. set up VS to launch your application with a specific parameter when debugging and then change the code to do something like this:

var mainForm = new FormToShowNormally();
#if DEBUG
if(debugParameterOnCommandLine) {
    mainForm = new FormToShowWhenDebugging();
}
#endif

Application.Run(mainForm);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜