Bonjour,
Je suis débutant en C#. Depuis plusieurs heures je bloque sur le problème suivant: j'ai deux pages form1 et form2. Lorsque je clique sur le bouton (Btn1) de form1 il doit ouvrir form2 dans laquelle je saisie une valeure (Txt1) qui doit être renvoyée dans form1 via un second bouton (Btn2).
Voici le code de Form1
Voici maintenant le code de Form2
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
33
34
35
36
37
38 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WTest { public partial class Form1 : Form { public Form1() { InitializeComponent(); private void textBox1_TextChanged(object sender, EventArgs e) { private string val; public string Val { set { val = value;} } textBox1.text=val; } } private void button1_Click(object sender, EventArgs e) { Form2 frm = new Form2(); frm.Show(); } } }
Ces codes me génèrent une dizaine d'erreurs.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WTest { public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void BtnOk_Click(object sender, EventArgs e) { Form1 frm = new Form1(); frm.Val = textBox1.Text; frm.Show(); } } }
Je ne comprends pas.
Quelqu'un peut il m'aider?
Partager