Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9124091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:29:41+00:00 2026-06-17T06:29:41+00:00

I have a main form window which will pop up a new form window.

  • 0

I have a main form window which will pop up a new form window. I want to lock the location of the popup form so that the window cannot be moved and it will move at the same time as the main form.
(so if a user drags the main form the popup moves with it)

Did a search on the site and some did it like this:

this.FormBorderStyle=System.Windows.Forms.FormBorderStyle.None

and I have the Locked attribute set to True but that doesn’t work.

But I want to keep the borders. What’s the proper way of locking a form?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:29:42+00:00Added an answer on June 17, 2026 at 6:29 am
    public class Form1
    {
        private Form2 Form2 = new Form2();
        private Point form2Location;
        private Point form1Location;
        private void Button1_Click(System.Object sender, System.EventArgs e)
        {
            form1Location = this.Location;
            Form2.Show();
            form2Location = Form2.Location;
        }
    
        private void Form1_Move(System.Object sender, System.EventArgs e)
        {
            Form2.IsMoving = true;
            Point form2OffSetLocation = new Point(this.Location.X - form2Location.X, this.Location.Y - form2Location.Y);
            Form2.Location = form2OffSetLocation;
            Form2.IsMoving = false;
        }
    }    
    
    public class Form2
    {
    
        public bool IsMoving;
        private void Form2_Move(System.Object sender, System.EventArgs e)
        {
            if (IsMoving) return; 
            if (staticLocation.X != 0 & staticLocation.Y != 0) this.Location = staticLocation; 
        }
    
        private Point staticLocation;
        private void Form2_Load(System.Object sender, System.EventArgs e)
        {
            staticLocation = this.Location;
        }
    }
    

    I agree with Hans on this one and I think once you see how dodgy it looks you’ll probably agree too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Switch to window button on my main form that I'd like
I have a form which instances a new form that I've already created using
I want to create a window that will be the main window and that
I have a main thread that creates a form object which creates and sets
I have a C# windows application which does the following: 1) the main form
I have a form MainForm which is a Windows Forms form that contains many
I have a windows form on the main thread and another thread that does
I have a Main form.I want to launch another form from it and launch
I have a main form, and a floating child form that is non-modal. The
Making a simple program which will generate a multiple choice form. I have an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.