C# move form

Posted on 2009-04-16
Medium Priority
Last Modified: 2013-11-07
I have to windows forms, form A and form B include in single EXE file. Is it possible to move both two form by clicking on and move one form only. For example click on form A and move, so form B also move
Question by:exprotein
  • 2

Accepted Solution

HarryNS earned 1500 total points
ID: 24156106
Create two forms Form 2 and 3. Form 2 code should be as below. Try it...
public partial class Form2 : Form
        Form3 frm = new Form3();
        public Form2()
        private void button1_Click(object sender, EventArgs e)
        private void Form2_Move(object sender, EventArgs e)
            frm.Location  = new Point( this.Location.X +10, this.Location.Y+10) ;

Open in new window

LVL 16

Expert Comment

ID: 24156111
Yes it is possible.

Handle the LocationChanged event of the first form.

In the handler you can set the Location Property of the second form with respect to the first form.

Author Closing Comment

ID: 31570898
It quite simple but correct, thanks :D

Author Comment

ID: 24156186
I wonder is there another ways to do move two forms, such as using window API. How about two form without border and titlebar ?

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month16 days, 11 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question