Setyo N
Setyo N

Reputation: 2103

How do I show a Form in maximized state in the same monitor as its parent?

How do I show a Form in maximized state in the same monitor as its parent?

I tried to run the following codes in a dual monitor system:

    using System.Windows.Forms;

    private void button1_Click( object sender, EventArgs e )
    {
      Form form2 = new Form();
      form2.StartPosition = FormStartPosition.CenterParent;
      form2.WindowState = FormWindowState.Maximized;
      form2.ShowDialog();
    }

but form2 is always shown in the primary monitor, even though its parent is on the secondary monitor.

Upvotes: 1

Views: 205

Answers (1)

Grant Winney
Grant Winney

Reputation: 66501

Specify the owner (parent), by passing it to ShowDialog():

form2.ShowDialog(this);

Upvotes: 1

Related Questions