Professional Documents
Culture Documents
Form.Show()
up I'm trying to set the location of a form when calling it by .Show(). The problem is
vote8do that because I'm using .Show instead of .ShowDialog the StartPosition value does
wn vote favorite
not work. I can't use the .Showdialog since I want the program to do work in the
1 background while showing the form.
When I'm creating the form I set it's location to a fixed value:
Robin
5842622
I hope below link has a fix. stackoverflow.com/questions/21171764/ user2852008 Sep 18 at 16:49
add a comment
2 Answers
activeoldest votes
Nor does switching place on the .location and .show Robin Jul 1 '13 at 8:34
When I look at the form closer it shows that it is actually not the new form that changes position. It's the main form
that changes startup position each time. However this is very odd since I've set the new forms location relative to th
main ones. Robin Jul 1 '13 at 8:41
add a comment
CF.StartPosition = FormStartPosition.Manual;
CF.Show(this);
......
}
On the new form's load event:
TL;DR the new form's location was not relative to the parent form's location,
but to a fixed position that I'm guessing is (0, 0)
I changed the MainForm's Startup Position to a fixed one for my own
convenience. I also added an event to make sure that the new forms position
always was the center of the MainForm.