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 16:36 
Hallo,

Problem diesmal:
Ich möchte, nachdem sich meine Form1 (Mainform) geöffnet/geladen hat, ein neues Fenster öffnen. Wenn ich dass in
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
public Mainform()
{
    InitializeComponent();
    Form2 f2 = new Form2();
    f2.showDialog();
}
mache, dann öffnet sich immer Form2 zuerst, da Mainform (glaube ich) noch nicht geladen ist.
Dann gibt es ja noch die Möglichkeit, das in die Event-Methode private void Mainform_Activated zu packen, allerdings öffnet sich dann Form2 nach dem schließen immer wieder, selbst mit Zähler-Variable.

Also ich möchte, dass sich Form2 nach Programmstart automatisch einmal öffnet und dann nicht mehr.
Frage: Wie?
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mo 14.03.16 16:46 
Nimm das Load- anstatt des Activated-Events ;-)

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
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 16:58 
das hatte ich so auch schon probiert
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
private void Mainform_Load(object sender,EventArgs e)
{
    Form2 f2 = new Form2();
    f2.showDialog();
}

Dann ist es aber dasselbe, d.h. f2 öffnet sich vor der Mainform und genau das will ich ja vermeiden
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 17:00 
Zitat:
Dann ist es aber dasselbe, d.h. f2 öffnet sich vor der Mainform und genau das will ich ja vermeiden


Vor ist da jetzt ein ganz unglückliches Wort :wink: Meinst du zeitlich vor oder räumlich vor?
Nach deiner Beschreibung möchtest du das räumliche vor dann nimm den Shown Event.

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 17:02 
ok das war's mal wieder. Danke an Ralf Jansen das zweite Mal heute schon :)