Hallo
Ich habe mir die FAQ durchgelesen. Leider klappt es noch nicht.
Ich habe 3 Formulare. Nachdem man in Form1 auf ein Button geklickt hat öffnet sich Form2 auf dem sich ein Textfeld befindet. Soweit funktioniert alles. Jetzt soll man über einen Button2 aus Form1 ein drittes Formular (Form3) öffnen können. In diesem Form3 soll der Inhalt, von dem Textfeld aus Form2, in einem Label ausgegeben werden.
Form1
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31:
| using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
private void button1_Click(object sender, EventArgs e) { Form2 frm2 = new Form2(); frm2.Show(); }
private void button2_Click(object sender, EventArgs e) { Form3 frm3 = new Form3(); frm3.Show(); } } } |
Form2
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32:
| using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
namespace WindowsFormsApplication1 { public partial class Form2 : Form { private string UserName = ""; public string User { get { return this.textBox1.Text; } set { this.UserName = value; } }
public Form2() { InitializeComponent(); }
private void button1_Click(object sender, EventArgs e) { if (this.textBox1.Text != null) { this.User = textBox1.Text; } this.Close(); } } } |
Wie bekomme ich den Wert aus Form2 in Form3? was mache ich falsch?
Gruß Doommortar