Autor Beitrag
kostonstyle
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 94



BeitragVerfasst: Do 11.08.11 16:48 
Hallo miteinander
ich habe 2 winforms fenster, und eins davon ist ein main fenster. Wenn der user bei main fenster den button "Zeig mir Forms 2" betätigt,
dann sollte das zweite Fenster gezeigt werden und auf dieses fokusieren. Das heisst, das main fenster ist solange nicht bedienbar,
bis form2 geschlossen wird. Wie realisiere ich so etwas?

Gruss kostonstyle
bakachan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 503
Erhaltene Danke: 34

W7 (x64) Ultimate
C# / VB.NET (VS2010 Ultimate)
BeitragVerfasst: Do 11.08.11 16:57 
Verwende ShowDialog() anstelle von Show().
kostonstyle Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 94



BeitragVerfasst: Fr 12.08.11 09:28 
vielen dank :-)
kostonstyle Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 94



BeitragVerfasst: Fr 12.08.11 09:35 
noch eine frage, wie kann ich daten aus dem main fenster zugreifen?
Ich möchte den wert aus der textbox1 von main fenster in fenster2 tranferieren.
wo kann ich globale variable definieren, dass für main und forms2 zugreifbar sind.
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4798
Erhaltene Danke: 1059

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Fr 12.08.11 09:48 
Hallo kostonstyle,

dazu lies dir am besten mal meinen Artikel Kommunikation von 2 Forms durch.
In Kürze:
- bei Übergabe an ein untergeordnetes Form: Eigenschaft definieren und verwenden
- bei Rückgabe eines Wertes an ein übergeordnetes (aufrufendes) Form:
--- bei modalen Fenster (ShowDialog): ebenfalls Eigenschaft definieren und verwenden
--- bei nicht-modalem Fenster (Show): Ereignis definieren und verwenden

Globale Variablen sollten nicht zur Kommunikation benutzt werden.