Bonjour,
J'ai écrit la procédure ci-dessous;
le problème est comment récupérer dans le 2ème MessageBox (lancé par Form2) la chaîne initialisée dans Form1.
SVP
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
39
40
41
42
43
44
45
46
47
48
49
50 ----------------------------------------------------------------- Classe namespace PorteeVarable { public class MyClass2 { public String var; } } ----------------------------------------------------------------- Form1 namespace PorteeVarable { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { MyClass2 myClass2 = new MyClass2(); myClass2.var = "ess3"; string i = myClass2.var; MessageBox.Show(i); } private void button1_Click(object sender, EventArgs e) { Form2 myForm = new Form2(); myForm.Show(); } ----------------------------------------------------------------- Form2 namespace PorteeVarable { public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void Form2_Load(object sender, EventArgs e) { MyClass2 myClass2b = new MyClass2(); //i2 = myClass2b.var; MessageBox.Show("valeur 2 = " + myClass2b.var); }
Partager