I start a new WindowsApp with Form1 with a Button. Added a form Form2 to my project. In the click event handler of my button I do the following:

private void button1_Click(object sender, EventArgs e)
        {
            Form2 F = new Form2();
            Point P = new Point(500, 500);
            F.Location = P;
            F.Show();
        }

Why does the second form always appears just below the title bar of the first form? Whatever I do with F.Location it shows always on the same place. Am I ommitting something?
Any suggestions are more than welcome.

Recommended Answers

All 4 Replies

Change the sequence of two statements:

F.Show();
            F.Location = P;
commented: Nice! +6

Thanks! So simple!

I start a new WindowsApp with Form1 with a Button. Added a form Form2 to my project. In the click event handler of my button I do the following:

private void button1_Click(object sender, EventArgs e)
        {
            Form2 F = new Form2();
            Point P = new Point(500, 500);
            F.Location = P;
            F.Show();
        }

Why does the second form always appears just below the title bar of the first form? Whatever I do with F.Location it shows always on the same place. Am I ommitting something?
Any suggestions are more than welcome.

------------------------------------

private void button1_Click(object sender, EventArgs e)
{

Form2 F = new Form2();

// insert this line
F.StartPosition = FormStartPosition.Manual;
// or set property StartPosition in design mode

Point P = new Point(500, 500);

F.Location = P;

F.Show();
}

commented: You really cleared it all out. +6

The flicker between the form transition still existed for me until I brought the new window in minimized, then set the location, then displayed it in the correct location.

viewShipments.WindowState = FormWindowState.Minimized;
viewShipments.Show();
viewShipments.Location = this.Location;
viewShipments.WindowState = FormWindowState.Normal;

Hope that helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.