Advertisement

05.15.2008 at 11:04AM PDT, ID: 23406109
[x]
Attachment Details

Re-centering Form1 after Form2 closes

Asked by rturney in Microsoft Visual C#.Net, C# Programming Language

Tags: Microsoft, C#, 2008

I have an application that has two forms, Form1 & Form2.  Form1 is the main form and Form2 is an image viewer.  Form1 starts up centered on the screen.  If an image needs to be viewed, Form2 is opened.  At the users request, Form2 will open at the upper left corner of the screen and Form1 will move from its centered position to the upper right corner of the screen.  This allows both Forms to viewed at the same time.  

The problem I have is re-centering Form1 when Form2 is closed.  

The code below which closes Form2 works as long as you don't move any other application Forms that may also be open at the time.  You can't move any application forms around, like a browser or another application that is sharing the screen before you close Form2.  If you do the following exception is thrown:

System.NullReferenceException was unhandled
  Message="Object reference not set to an instance of an object."

Thanks,
-BobStart Free Trial
1:
2:
3:
4:
5:
6:
7:
private void buttonClose_Click(object sender, EventArgs e)
        {
            this.Close();
 
            Form1.ActiveForm.Top = 312;
            Form1.ActiveForm.Left = 588;
        }
[+][-]05.15.2008 at 05:18PM PDT, ID: 21578937

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.16.2008 at 05:58AM PDT, ID: 21582250

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.16.2008 at 06:21AM PDT, ID: 21582405

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.16.2008 at 07:00AM PDT, ID: 21582696

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.19.2008 at 06:35AM PDT, ID: 21597608

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.19.2008 at 07:47AM PDT, ID: 21598252

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.19.2008 at 08:00AM PDT, ID: 21598375

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.19.2008 at 08:15AM PDT, ID: 21598507

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.19.2008 at 08:29AM PDT, ID: 21598641

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.19.2008 at 09:10AM PDT, ID: 21599025

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.19.2008 at 09:29AM PDT, ID: 21599237

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual C#.Net, C# Programming Language
Tags: Microsoft, C#, 2008
Sign Up Now!
Solution Provided By: BillyDvD
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05.19.2008 at 10:47AM PDT, ID: 21599944

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.19.2008 at 10:49AM PDT, ID: 21599961

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.19.2008 at 10:57AM PDT, ID: 21600025

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.19.2008 at 10:59AM PDT, ID: 21600041

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628