MDI Child.show () zeigt das Formular in einer seltsamen Art und Weise
Frage
Ich habe ein Hauptformular, das 5 MDI Kinder hat. Wenn das Hauptformular erstellt wird, werden die mdi Kinder geschaffen und auch gezeigt.
I weisen sie verschiedene Orte auf dem Bildschirm, aber wenn sie sie mit dem Standardverzeichnis starten gezeigt und in störender Weise zu den neuen Standorten pendeln. Ich habe versucht, den Standort zuweisen, bevor ich die Formen zeigen, aber wie erwartet nach dem Aufruf the.Show () sie neigen dazu, zu einem gewissen Standard-Speicherort zu gehen. Gibt es trotzdem von der Standardeinstellung der neuen Standorte zeigen diese Bewegung zu vermeiden?
Hier ist ein Codefragment
groupSettingsForm.Show();
groupSettingsForm.Location = new Point(0, 0);
dsForm.Show();
dsForm.Location = new Point(groupSettingsForm.Width, 0);
dPlots.Show();
dPlots.Location = new Point(groupSettingsForm.Width, dsForm.Height);
alertsForm.Show();
alertsForm.Location = new Point(groupSettingsForm.Width, dsForm.Height + dPlots.Height);
dataValuesForm.Show();
dataValuesForm.Location = new Point(0, groupSettingsForm.Height);
Ich habe versucht, aber es hat nicht funktioniert für mich
groupSettingsForm.Location = new Point(0, 0);
groupSettingsForm.Show();
dsForm.Location = new Point(groupSettingsForm.Width, 0);
dsForm.Show();
dPlots.Location = new Point(groupSettingsForm.Width, dsForm.Height);
dPlots.Show();
alertsForm.Location = new Point(groupSettingsForm.Width, dsForm.Height + dPlots.Height);
alertsForm.Show();
dataValuesForm.Location = new Point(0, groupSettingsForm.Height);
dataValuesForm.Show();
Lösung
Ich hatte gerade etwas Ähnliches wie diese - meine Frage gefunden sie hier.
Sie müssen die StartPosition
Eigenschaft auf FormStartPosition.Manual
:
form.StartPosition = FormStartPosition.Manual;
form.Location = new System.Drawing.Point(0, 0);