Autor Beitrag
erfahrener Neuling
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 233
Erhaltene Danke: 19

Win 7, Win 10
C#, ASP-MVC (VS 2017 Community), MS SQL, Firebird SQL
BeitragVerfasst: Mo 14.03.16 12:43 
Hi ich bin's mal wieder.

Diesmal möchte ich, dass meine 2. Form mittig von der 1. Form gestartet wird.
Wenn ich das so umsetze,

ausblenden C#-Quelltext
1:
2:
3:
Anmeldefenster AMF = new Anmeldefenster();
AMF.Location = new Point(this.Location.X, this.Location.Y);     //nichts passiert
if(AMF.ShowDialog() == DialogResult.OK) { MessageBox.Show("Login funktioniert"); }

ändert sich gar nichts an der Position (egal ob mittig oder nicht).
Auch mit this.DesktopLocation hat sich nichts geändert.

Woran liegt dass, bzw wie setze ich die Location mittig von Form1?
Ralf Jansen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 4708
Erhaltene Danke: 991


VS2010 Pro, VS2012 Pro, VS2013 Pro, VS2015 Pro, Delphi 7 Pro
BeitragVerfasst: Mo 14.03.16 12:51 
Übergebe eine Parent Form an ShowDialog damit diese Form auch weiss wovor sie angezeigt werden soll (AMF.ShowDialog(this)) und setze bei der AMF Form die StartPosition Property auf CenterParent.

Für diesen Beitrag haben gedankt: erfahrener Neuling
erfahrener Neuling Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 233
Erhaltene Danke: 19

Win 7, Win 10
C#, ASP-MVC (VS 2017 Community), MS SQL, Firebird SQL
BeitragVerfasst: Mo 14.03.16 13:00 
Danke genau das was ich brauchte ;)