tags:

views:

220

answers:

2

I am creating a simple dialogue window in C#, and want to remember where it is placed so that I can open another in the same place later (during the same application run, so no need for config files etc). I can easily save the Location (a Point) or the Bounds (a Rectangle), but on creating another form, calling form.ShowDialog() resets both:

 Form form= new Form();   

 form.Location = ptSavedLocation;
 //now form.Location is correct

 form.ShowDialog();
 //now form.Location is default again, and form is displayed where I don't want it.

How can I get the form to respect its Location (or Bounds, or any other appropriate property / setter) ? Thanks!

+4  A: 

Set the forms start position to Manual

eg.

 Form form= new Form();   

 form.StartPosition = FormStartPosition.Manual;

 form.Location = ptSavedLocation;
 //now form.Location is correct

 form.ShowDialog();
 //now form.Location is default again, and form is displayed where I don't want it.
PaulB
thanks, that was what I was looking for.
Joel in Gö
A: 

Set the forms StartPosition property to Manual

geoff