Hi, I've got 2 forms, after click on the button I'm hiding first and showing second..
How to put the second form to the same location as first one?
I've tried:

        MMenu m = new MMenu(); // MMenu is the first form
        this.Width = m.Width; //Width and Height lines are working OK.
        this.Height = m.Height;
        this.Left = m.Left; //These two are not. I have already tried this.Location = m.Location - no success
        this.Top = m.Top;

Thanks for you help :)

Dani AI

Generated

Good instincts from — this is almost always an order‑of‑operations / StartPosition issue in WinForms. By default a form’s StartPosition (CenterScreen, WindowsDefaultLocation, etc.) or the OS positioning logic can override Left/Top set too early, and a form’s handle/window state can change positioning when it’s shown. Below are concise, reliable ways to make the second form appear exactly where the first one was.

A simple, robust approach: set the form to manual positioning, copy the bounds (location + size), then show it. This copies borders/titlebar too, so the new form overlays the old one exactly.

var f2 = new SecondForm();
f2.StartPosition = FormStartPosition.Manual;
f2.Bounds = firstForm.Bounds;   // copies location + size
f2.Show(firstForm);            // optional: set owner

If you prefer to move the window after it has been created, do the repositioning in the Shown event (or use BeginInvoke) so you’re changing location after WinForms/OS placement is finished:

f2.Shown += (s,e) => { f2.Location = firstForm.Location; };
f2.Show();

Quick troubleshooting checklist:

  • Ensure StartPosition = Manual if you set Location before showing.
  • If the form is Maximized/Minimized, set WindowState = FormWindowState.Normal before changing bounds.
  • For MDI children or coordinates relative to a control, convert with PointToScreen or use Screen.FromControl for multi-monitor/DPI issues.
  • If something still repositions, accessing the form’s Handle or using the Shown event forces stable positioning.

These approaches cover the usual pitfalls and make the placement deterministic across monitors and DPI settings.

I have already solved it myself, problem was, that I need to Show second form first and then set its Position :)

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.