質問編集履歴

1

form1のコード追加しました。よろしくお願いします。

2017/05/06 23:34

投稿

n.k8808
n.k8808

スコア25

test CHANGED
File without changes
test CHANGED
@@ -1,7 +1,5 @@
1
1
  子formで親formの変数を取得したいです
2
2
 
3
- public としても
4
-
5
3
  (と言う名前は存在しません)と出てきます
6
4
 
7
5
 
@@ -9,3 +7,231 @@
9
7
  どうすればいいですか
10
8
 
11
9
  お願いします。
10
+
11
+
12
+
13
+ form1
14
+
15
+ ```C#
16
+
17
+ using System;
18
+
19
+ using System.Collections.Generic;
20
+
21
+ using System.ComponentModel;
22
+
23
+ using System.Data;
24
+
25
+ using System.Drawing;
26
+
27
+ using System.Linq;
28
+
29
+ using System.Text;
30
+
31
+ using System.Threading.Tasks;
32
+
33
+ using System.Windows.Forms;
34
+
35
+
36
+
37
+ namespace WindowsFormsApp1
38
+
39
+ {
40
+
41
+ public partial class Form1 : Form
42
+
43
+ {
44
+
45
+ public Form1()
46
+
47
+ {
48
+
49
+ InitializeComponent();
50
+
51
+ }
52
+
53
+
54
+
55
+ private void button1_Click(object sender, EventArgs e)
56
+
57
+ {
58
+
59
+ string n1 = textBox1.Text;
60
+
61
+ }
62
+
63
+ }
64
+
65
+ }
66
+
67
+ ```
68
+
69
+ ```C#
70
+
71
+ namespace WindowsFormsApp1
72
+
73
+ {
74
+
75
+ partial class Form1
76
+
77
+ {
78
+
79
+ /// <summary>
80
+
81
+ /// Required designer variable.
82
+
83
+ /// </summary>
84
+
85
+ private System.ComponentModel.IContainer components = null;
86
+
87
+
88
+
89
+ /// <summary>
90
+
91
+ /// Clean up any resources being used.
92
+
93
+ /// </summary>
94
+
95
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
96
+
97
+ protected override void Dispose(bool disposing)
98
+
99
+ {
100
+
101
+ if (disposing && (components != null))
102
+
103
+ {
104
+
105
+ components.Dispose();
106
+
107
+ }
108
+
109
+ base.Dispose(disposing);
110
+
111
+ }
112
+
113
+
114
+
115
+ #region Windows Form Designer generated code
116
+
117
+
118
+
119
+ /// <summary>
120
+
121
+ /// Required method for Designer support - do not modify
122
+
123
+ /// the contents of this method with the code editor.
124
+
125
+ /// </summary>
126
+
127
+ private void InitializeComponent()
128
+
129
+ {
130
+
131
+ this.textBox1 = new System.Windows.Forms.TextBox();
132
+
133
+ this.button1 = new System.Windows.Forms.Button();
134
+
135
+ this.SuspendLayout();
136
+
137
+ //
138
+
139
+ // textBox1
140
+
141
+ //
142
+
143
+ this.textBox1.Location = new System.Drawing.Point(1, 0);
144
+
145
+ this.textBox1.Name = "textBox1";
146
+
147
+ this.textBox1.Size = new System.Drawing.Size(100, 19);
148
+
149
+ this.textBox1.TabIndex = 0;
150
+
151
+ //
152
+
153
+ // button1
154
+
155
+ //
156
+
157
+ this.button1.Location = new System.Drawing.Point(108, 0);
158
+
159
+ this.button1.Name = "button1";
160
+
161
+ this.button1.Size = new System.Drawing.Size(75, 23);
162
+
163
+ this.button1.TabIndex = 1;
164
+
165
+ this.button1.Text = "button1";
166
+
167
+ this.button1.UseVisualStyleBackColor = true;
168
+
169
+ this.button1.Click += new System.EventHandler(this.button1_Click);
170
+
171
+ //
172
+
173
+ // Form1
174
+
175
+ //
176
+
177
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
178
+
179
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
180
+
181
+ this.ClientSize = new System.Drawing.Size(284, 261);
182
+
183
+ this.Controls.Add(this.button1);
184
+
185
+ this.Controls.Add(this.textBox1);
186
+
187
+ this.Name = "Form1";
188
+
189
+ this.Text = "Form1";
190
+
191
+ this.ResumeLayout(false);
192
+
193
+ this.PerformLayout();
194
+
195
+
196
+
197
+ }
198
+
199
+
200
+
201
+ #endregion
202
+
203
+
204
+
205
+ private System.Windows.Forms.TextBox textBox1;
206
+
207
+ private System.Windows.Forms.Button button1;
208
+
209
+ }
210
+
211
+ }
212
+
213
+ ```
214
+
215
+ form2
216
+
217
+ ```C#
218
+
219
+ //
220
+
221
+ // label1
222
+
223
+ //
224
+
225
+ this.label1.AutoSize = true;
226
+
227
+ this.label1.Location = new System.Drawing.Point(1, 1);
228
+
229
+ this.label1.Name = "label1";
230
+
231
+ this.label1.Size = new System.Drawing.Size(35, 12);
232
+
233
+ this.label1.TabIndex = 0;
234
+
235
+ this.label1.Text = n1;
236
+
237
+ ```