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.NullReferenceExcept
ion was unhandled
Message="Object reference not set to an instance of an object."
Thanks,
-Bob
Start Free Trial