回答編集履歴
3
見直しキャンペーン中
test
CHANGED
@@ -1,475 +1,235 @@
|
|
1
1
|
`Application.Run(Form1.GetInstance());`
|
2
|
-
|
3
2
|
こうしてください。
|
4
3
|
|
5
|
-
|
6
|
-
|
7
4
|
---
|
8
5
|
|
9
|
-
|
10
|
-
|
11
6
|
今の状況というか問題点は、
|
12
|
-
|
13
7
|
1. メインフォームとサブフォーム1-13は既にできていて、動作自体に問題はない
|
14
|
-
|
15
8
|
2. サブフォームを排他的(どれか一つだけしか開けないよう)に改造しようとしている
|
16
|
-
|
17
9
|
3. その際地道にやれば(コメントアウトのコード)できることはわかっている
|
18
|
-
|
19
10
|
4. しかし13個はだるいし、もっといい方法がありそうに思える
|
20
11
|
|
21
|
-
|
22
|
-
|
23
12
|
ってことですよね?(実際2個目くらいでもうだるかったです^^;
|
24
13
|
|
25
|
-
|
26
|
-
|
27
14
|
自分だったらこうするかなぁ?ってコードです。
|
28
|
-
|
29
15
|
`button1_Click`もまとめてもよさそうですが、行数も減りそうにないのでそのまま。
|
30
16
|
|
31
|
-
|
32
|
-
|
33
|
-
Form1.cs
|
17
|
+
```cs:Form1.cs
|
34
|
-
|
35
|
-
```C#
|
36
|
-
|
37
18
|
using System;
|
38
|
-
|
39
19
|
using System.Drawing;
|
40
|
-
|
41
20
|
using System.Windows.Forms;
|
42
21
|
|
43
|
-
|
44
|
-
|
45
22
|
namespace Questions293390
|
46
|
-
|
47
23
|
{
|
48
|
-
|
49
24
|
public partial class Form1 : Form
|
50
|
-
|
51
|
-
{
|
25
|
+
{
|
52
|
-
|
53
26
|
// シングルトンの必要はないかもしれないが、どうせSubFormからForm1をいじりたくなりますよね?
|
54
|
-
|
55
27
|
public static Form1 Instance { get; } = new Form1();
|
56
28
|
|
57
|
-
|
58
|
-
|
59
29
|
private Form1() => InitializeComponent();
|
60
30
|
|
61
|
-
|
62
|
-
|
63
31
|
private void button1_Click(object sender, EventArgs e)
|
64
|
-
|
65
32
|
=> ShowSubForm(new SubForm1(), panel1);
|
66
33
|
|
67
|
-
|
68
|
-
|
69
34
|
private void button2_Click(object sender, EventArgs e)
|
70
|
-
|
71
35
|
=> ShowSubForm(new SubForm2(), panel1);
|
72
36
|
|
73
|
-
|
74
|
-
|
75
37
|
private void button3_Click(object sender, EventArgs e)
|
76
|
-
|
77
38
|
=> ShowSubForm(new SubForm3(), panel1);
|
78
39
|
|
79
|
-
|
80
|
-
|
81
40
|
// class Commonにあっても別に構わない
|
82
|
-
|
83
41
|
private static void ShowSubForm(Form subForm, Panel group)
|
84
|
-
|
85
|
-
{
|
42
|
+
{
|
86
|
-
|
87
43
|
// Panel配下のボタンを不活性
|
88
|
-
|
89
44
|
foreach(var control in group.Controls)
|
90
|
-
|
91
45
|
{
|
92
|
-
|
93
46
|
if(control is Button button)
|
94
|
-
|
95
47
|
button.Enabled = false;
|
96
|
-
|
97
48
|
}
|
98
49
|
|
99
|
-
|
100
|
-
|
101
50
|
// SubFormのクローズを購読
|
102
|
-
|
103
51
|
subForm.FormClosed += SubForm_FormClosed;
|
104
|
-
|
105
52
|
// PanelをTagに入れて覚えておく
|
106
|
-
|
107
53
|
subForm.Tag = group;
|
108
|
-
|
109
54
|
subForm.Show();
|
110
|
-
|
111
|
-
}
|
55
|
+
}
|
112
|
-
|
113
|
-
|
114
56
|
|
115
57
|
// クローズ時にPanel配下のボタンを戻す
|
116
|
-
|
117
58
|
private static void SubForm_FormClosed(object sender, FormClosedEventArgs e)
|
118
|
-
|
119
|
-
{
|
59
|
+
{
|
120
|
-
|
121
60
|
// senderはSubForm自身
|
122
|
-
|
123
61
|
if(sender is Form subForm)
|
124
|
-
|
125
62
|
{
|
126
|
-
|
127
63
|
// PanelをTagから取り出す
|
128
|
-
|
129
64
|
if(subForm.Tag is Panel group)
|
130
|
-
|
131
65
|
{
|
132
|
-
|
133
66
|
foreach(var control in group.Controls)
|
134
|
-
|
135
67
|
{
|
136
|
-
|
137
68
|
if(control is Button button)
|
138
|
-
|
139
69
|
button.Enabled = true;
|
140
|
-
|
141
70
|
}
|
142
|
-
|
143
71
|
}
|
144
|
-
|
145
72
|
}
|
146
|
-
|
147
|
-
}
|
73
|
+
}
|
148
|
-
|
149
|
-
}
|
74
|
+
}
|
150
|
-
|
151
|
-
|
152
75
|
|
153
76
|
// SubFormではFormClosed等のイベントを書く必要がなくて楽々という意味
|
154
|
-
|
155
77
|
// 実際は普通に作る
|
156
|
-
|
157
78
|
public class SubForm1 : Form
|
158
|
-
|
159
|
-
{
|
79
|
+
{
|
160
|
-
|
161
80
|
public SubForm1() { Text = "SubForm1"; ClientSize = new Size(300, 200); }
|
162
|
-
|
163
|
-
}
|
81
|
+
}
|
164
|
-
|
165
82
|
public class SubForm2 : Form
|
166
|
-
|
167
|
-
{
|
83
|
+
{
|
168
|
-
|
169
84
|
public SubForm2() { Text = "SubForm2"; ClientSize = new Size(300, 200); }
|
170
|
-
|
171
|
-
}
|
85
|
+
}
|
172
|
-
|
173
86
|
public class SubForm3 : Form
|
174
|
-
|
175
|
-
{
|
87
|
+
{
|
176
|
-
|
177
88
|
public SubForm3() { Text = "SubForm3"; ClientSize = new Size(300, 200); }
|
178
|
-
|
179
|
-
}
|
89
|
+
}
|
180
|
-
|
181
90
|
}
|
182
|
-
|
183
91
|
```
|
184
92
|
|
185
|
-
|
186
|
-
|
187
|
-
Form1.Designer.cs
|
93
|
+
```cs:Form1.Designer.cs
|
188
|
-
|
189
|
-
```C#
|
190
|
-
|
191
94
|
namespace Questions293390
|
192
|
-
|
193
95
|
{
|
194
|
-
|
195
96
|
partial class Form1
|
196
|
-
|
197
|
-
{
|
97
|
+
{
|
198
|
-
|
199
98
|
/// <summary>
|
200
|
-
|
201
99
|
/// 必要なデザイナー変数です。
|
202
|
-
|
203
100
|
/// </summary>
|
204
|
-
|
205
101
|
private System.ComponentModel.IContainer components = null;
|
206
102
|
|
207
|
-
|
208
|
-
|
209
103
|
/// <summary>
|
210
|
-
|
211
104
|
/// 使用中のリソースをすべてクリーンアップします。
|
212
|
-
|
213
105
|
/// </summary>
|
214
|
-
|
215
106
|
/// <param name="disposing">マネージド リソースを破棄する場合は true を指定し、その他の場合は false を指定します。</param>
|
216
|
-
|
217
107
|
protected override void Dispose(bool disposing)
|
218
|
-
|
219
|
-
{
|
108
|
+
{
|
220
|
-
|
221
109
|
if(disposing && (components != null))
|
222
|
-
|
223
110
|
{
|
224
|
-
|
225
111
|
components.Dispose();
|
226
|
-
|
227
112
|
}
|
228
|
-
|
229
113
|
base.Dispose(disposing);
|
230
|
-
|
231
|
-
}
|
114
|
+
}
|
232
|
-
|
233
|
-
|
234
115
|
|
235
116
|
#region Windows フォーム デザイナーで生成されたコード
|
236
117
|
|
237
|
-
|
238
|
-
|
239
118
|
/// <summary>
|
240
|
-
|
241
119
|
/// デザイナー サポートに必要なメソッドです。このメソッドの内容を
|
242
|
-
|
243
120
|
/// コード エディターで変更しないでください。
|
244
|
-
|
245
121
|
/// </summary>
|
246
|
-
|
247
122
|
private void InitializeComponent()
|
248
|
-
|
249
|
-
{
|
123
|
+
{
|
250
|
-
|
251
124
|
this.button1 = new System.Windows.Forms.Button();
|
252
|
-
|
253
125
|
this.button2 = new System.Windows.Forms.Button();
|
254
|
-
|
255
126
|
this.button3 = new System.Windows.Forms.Button();
|
256
|
-
|
257
127
|
this.panel1 = new System.Windows.Forms.Panel();
|
258
|
-
|
259
128
|
this.otherButton = new System.Windows.Forms.Button();
|
260
|
-
|
261
129
|
this.label1 = new System.Windows.Forms.Label();
|
262
|
-
|
263
130
|
this.panel1.SuspendLayout();
|
264
|
-
|
265
131
|
this.SuspendLayout();
|
266
|
-
|
267
|
-
//
|
132
|
+
//
|
268
|
-
|
269
133
|
// button1
|
270
|
-
|
271
|
-
//
|
134
|
+
//
|
272
|
-
|
273
135
|
this.button1.Location = new System.Drawing.Point(5, 34);
|
274
|
-
|
275
136
|
this.button1.Name = "button1";
|
276
|
-
|
277
137
|
this.button1.Size = new System.Drawing.Size(75, 23);
|
278
|
-
|
279
138
|
this.button1.TabIndex = 0;
|
280
|
-
|
281
139
|
this.button1.Text = "button1";
|
282
|
-
|
283
140
|
this.button1.UseVisualStyleBackColor = true;
|
284
|
-
|
285
141
|
this.button1.Click += new System.EventHandler(this.button1_Click);
|
286
|
-
|
287
|
-
//
|
142
|
+
//
|
288
|
-
|
289
143
|
// button2
|
290
|
-
|
291
|
-
//
|
144
|
+
//
|
292
|
-
|
293
145
|
this.button2.Location = new System.Drawing.Point(5, 63);
|
294
|
-
|
295
146
|
this.button2.Name = "button2";
|
296
|
-
|
297
147
|
this.button2.Size = new System.Drawing.Size(75, 23);
|
298
|
-
|
299
148
|
this.button2.TabIndex = 1;
|
300
|
-
|
301
149
|
this.button2.Text = "button2";
|
302
|
-
|
303
150
|
this.button2.UseVisualStyleBackColor = true;
|
304
|
-
|
305
151
|
this.button2.Click += new System.EventHandler(this.button2_Click);
|
306
|
-
|
307
|
-
//
|
152
|
+
//
|
308
|
-
|
309
153
|
// button3
|
310
|
-
|
311
|
-
//
|
154
|
+
//
|
312
|
-
|
313
155
|
this.button3.Location = new System.Drawing.Point(5, 92);
|
314
|
-
|
315
156
|
this.button3.Name = "button3";
|
316
|
-
|
317
157
|
this.button3.Size = new System.Drawing.Size(75, 23);
|
318
|
-
|
319
158
|
this.button3.TabIndex = 2;
|
320
|
-
|
321
159
|
this.button3.Text = "button3";
|
322
|
-
|
323
160
|
this.button3.UseVisualStyleBackColor = true;
|
324
|
-
|
325
161
|
this.button3.Click += new System.EventHandler(this.button3_Click);
|
326
|
-
|
327
|
-
//
|
162
|
+
//
|
328
|
-
|
329
163
|
// panel1
|
330
|
-
|
331
|
-
//
|
164
|
+
//
|
332
|
-
|
333
165
|
this.panel1.Controls.Add(this.label1);
|
334
|
-
|
335
166
|
this.panel1.Controls.Add(this.button3);
|
336
|
-
|
337
167
|
this.panel1.Controls.Add(this.button1);
|
338
|
-
|
339
168
|
this.panel1.Controls.Add(this.button2);
|
340
|
-
|
341
169
|
this.panel1.Location = new System.Drawing.Point(153, 136);
|
342
|
-
|
343
170
|
this.panel1.Name = "panel1";
|
344
|
-
|
345
171
|
this.panel1.Size = new System.Drawing.Size(112, 125);
|
346
|
-
|
347
172
|
this.panel1.TabIndex = 3;
|
348
|
-
|
349
|
-
//
|
173
|
+
//
|
350
|
-
|
351
174
|
// otherButton
|
352
|
-
|
353
|
-
//
|
175
|
+
//
|
354
|
-
|
355
176
|
this.otherButton.Location = new System.Drawing.Point(538, 54);
|
356
|
-
|
357
177
|
this.otherButton.Name = "otherButton";
|
358
|
-
|
359
178
|
this.otherButton.Size = new System.Drawing.Size(75, 23);
|
360
|
-
|
361
179
|
this.otherButton.TabIndex = 4;
|
362
|
-
|
363
180
|
this.otherButton.Text = "otherButton";
|
364
|
-
|
365
181
|
this.otherButton.UseVisualStyleBackColor = true;
|
366
|
-
|
367
|
-
//
|
182
|
+
//
|
368
|
-
|
369
183
|
// label1
|
370
|
-
|
371
|
-
//
|
184
|
+
//
|
372
|
-
|
373
185
|
this.label1.AutoSize = true;
|
374
|
-
|
375
186
|
this.label1.Location = new System.Drawing.Point(3, 10);
|
376
|
-
|
377
187
|
this.label1.Name = "label1";
|
378
|
-
|
379
188
|
this.label1.Size = new System.Drawing.Size(35, 12);
|
380
|
-
|
381
189
|
this.label1.TabIndex = 3;
|
382
|
-
|
383
190
|
this.label1.Text = "label1";
|
384
|
-
|
385
|
-
//
|
191
|
+
//
|
386
|
-
|
387
192
|
// Form1
|
388
|
-
|
389
|
-
//
|
193
|
+
//
|
390
|
-
|
391
194
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
392
|
-
|
393
195
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
394
|
-
|
395
196
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
396
|
-
|
397
197
|
this.Controls.Add(this.otherButton);
|
398
|
-
|
399
198
|
this.Controls.Add(this.panel1);
|
400
|
-
|
401
199
|
this.Name = "Form1";
|
402
|
-
|
403
200
|
this.Text = "Form1";
|
404
|
-
|
405
201
|
this.panel1.ResumeLayout(false);
|
406
|
-
|
407
202
|
this.panel1.PerformLayout();
|
408
|
-
|
409
203
|
this.ResumeLayout(false);
|
410
204
|
|
411
|
-
|
412
|
-
|
413
|
-
}
|
205
|
+
}
|
414
|
-
|
415
|
-
|
416
206
|
|
417
207
|
#endregion
|
418
|
-
|
419
208
|
private System.Windows.Forms.Label label1;
|
420
|
-
|
421
209
|
private System.Windows.Forms.Button otherButton;
|
422
|
-
|
423
210
|
private System.Windows.Forms.Button button1;
|
424
|
-
|
425
211
|
private System.Windows.Forms.Button button2;
|
426
|
-
|
427
212
|
private System.Windows.Forms.Button button3;
|
428
|
-
|
429
213
|
private System.Windows.Forms.Panel panel1;
|
430
|
-
|
431
|
-
}
|
214
|
+
}
|
432
|
-
|
433
215
|
}
|
434
|
-
|
435
216
|
```
|
436
217
|
|
437
|
-
|
438
|
-
|
439
|
-
Program.cs
|
218
|
+
```cs:Program.cs
|
440
|
-
|
441
|
-
```C#
|
442
|
-
|
443
219
|
using System;
|
444
|
-
|
445
220
|
using System.Windows.Forms;
|
446
221
|
|
447
|
-
|
448
|
-
|
449
222
|
namespace Questions293390
|
450
|
-
|
451
223
|
{
|
452
|
-
|
453
224
|
static class Program
|
454
|
-
|
455
|
-
{
|
225
|
+
{
|
456
|
-
|
457
226
|
[STAThread]
|
458
|
-
|
459
227
|
static void Main()
|
460
|
-
|
461
|
-
{
|
228
|
+
{
|
462
|
-
|
463
229
|
Application.EnableVisualStyles();
|
464
|
-
|
465
230
|
Application.SetCompatibleTextRenderingDefault(false);
|
466
|
-
|
467
231
|
Application.Run(Form1.Instance);
|
468
|
-
|
469
|
-
}
|
232
|
+
}
|
470
|
-
|
471
|
-
}
|
233
|
+
}
|
472
|
-
|
473
234
|
}
|
474
|
-
|
475
235
|
```
|
2
メソッド化
test
CHANGED
@@ -84,7 +84,7 @@
|
|
84
84
|
|
85
85
|
{
|
86
86
|
|
87
|
-
//
|
87
|
+
// Panel配下のボタンを不活性
|
88
88
|
|
89
89
|
foreach(var control in group.Controls)
|
90
90
|
|
@@ -98,29 +98,47 @@
|
|
98
98
|
|
99
99
|
|
100
100
|
|
101
|
+
// SubFormのクローズを購読
|
102
|
+
|
101
|
-
subForm.FormClosed += Closed;
|
103
|
+
subForm.FormClosed += SubForm_FormClosed;
|
104
|
+
|
105
|
+
// PanelをTagに入れて覚えておく
|
106
|
+
|
107
|
+
subForm.Tag = group;
|
102
108
|
|
103
109
|
subForm.Show();
|
104
110
|
|
105
|
-
|
111
|
+
}
|
106
|
-
|
112
|
+
|
113
|
+
|
114
|
+
|
107
|
-
|
115
|
+
// クローズ時にPanel配下のボタンを戻す
|
108
|
-
|
116
|
+
|
109
|
-
|
117
|
+
private static void SubForm_FormClosed(object sender, FormClosedEventArgs e)
|
118
|
+
|
119
|
+
{
|
120
|
+
|
121
|
+
// senderはSubForm自身
|
122
|
+
|
123
|
+
if(sender is Form subForm)
|
110
124
|
|
111
125
|
{
|
112
126
|
|
127
|
+
// PanelをTagから取り出す
|
128
|
+
|
113
|
-
subForm.
|
129
|
+
if(subForm.Tag is Panel group)
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
foreach(var control in group.Controls)
|
118
130
|
|
119
131
|
{
|
120
132
|
|
133
|
+
foreach(var control in group.Controls)
|
134
|
+
|
135
|
+
{
|
136
|
+
|
121
|
-
if(control is Button button)
|
137
|
+
if(control is Button button)
|
122
|
-
|
138
|
+
|
123
|
-
button.Enabled = true;
|
139
|
+
button.Enabled = true;
|
140
|
+
|
141
|
+
}
|
124
142
|
|
125
143
|
}
|
126
144
|
|
1
コード追記
test
CHANGED
@@ -1,3 +1,457 @@
|
|
1
1
|
`Application.Run(Form1.GetInstance());`
|
2
2
|
|
3
3
|
こうしてください。
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
---
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
今の状況というか問題点は、
|
12
|
+
|
13
|
+
1. メインフォームとサブフォーム1-13は既にできていて、動作自体に問題はない
|
14
|
+
|
15
|
+
2. サブフォームを排他的(どれか一つだけしか開けないよう)に改造しようとしている
|
16
|
+
|
17
|
+
3. その際地道にやれば(コメントアウトのコード)できることはわかっている
|
18
|
+
|
19
|
+
4. しかし13個はだるいし、もっといい方法がありそうに思える
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
ってことですよね?(実際2個目くらいでもうだるかったです^^;
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
自分だったらこうするかなぁ?ってコードです。
|
28
|
+
|
29
|
+
`button1_Click`もまとめてもよさそうですが、行数も減りそうにないのでそのまま。
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
Form1.cs
|
34
|
+
|
35
|
+
```C#
|
36
|
+
|
37
|
+
using System;
|
38
|
+
|
39
|
+
using System.Drawing;
|
40
|
+
|
41
|
+
using System.Windows.Forms;
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
namespace Questions293390
|
46
|
+
|
47
|
+
{
|
48
|
+
|
49
|
+
public partial class Form1 : Form
|
50
|
+
|
51
|
+
{
|
52
|
+
|
53
|
+
// シングルトンの必要はないかもしれないが、どうせSubFormからForm1をいじりたくなりますよね?
|
54
|
+
|
55
|
+
public static Form1 Instance { get; } = new Form1();
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
private Form1() => InitializeComponent();
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
private void button1_Click(object sender, EventArgs e)
|
64
|
+
|
65
|
+
=> ShowSubForm(new SubForm1(), panel1);
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
private void button2_Click(object sender, EventArgs e)
|
70
|
+
|
71
|
+
=> ShowSubForm(new SubForm2(), panel1);
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
private void button3_Click(object sender, EventArgs e)
|
76
|
+
|
77
|
+
=> ShowSubForm(new SubForm3(), panel1);
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
// class Commonにあっても別に構わない
|
82
|
+
|
83
|
+
private static void ShowSubForm(Form subForm, Panel group)
|
84
|
+
|
85
|
+
{
|
86
|
+
|
87
|
+
// group配下のボタンを不活性
|
88
|
+
|
89
|
+
foreach(var control in group.Controls)
|
90
|
+
|
91
|
+
{
|
92
|
+
|
93
|
+
if(control is Button button)
|
94
|
+
|
95
|
+
button.Enabled = false;
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
subForm.FormClosed += Closed;
|
102
|
+
|
103
|
+
subForm.Show();
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
// クローズ時にgroup配下のボタンを活性に戻す
|
108
|
+
|
109
|
+
void Closed(object sender, FormClosedEventArgs e)
|
110
|
+
|
111
|
+
{
|
112
|
+
|
113
|
+
subForm.FormClosed -= Closed;
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
foreach(var control in group.Controls)
|
118
|
+
|
119
|
+
{
|
120
|
+
|
121
|
+
if(control is Button button)
|
122
|
+
|
123
|
+
button.Enabled = true;
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
}
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
}
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
// SubFormではFormClosed等のイベントを書く必要がなくて楽々という意味
|
136
|
+
|
137
|
+
// 実際は普通に作る
|
138
|
+
|
139
|
+
public class SubForm1 : Form
|
140
|
+
|
141
|
+
{
|
142
|
+
|
143
|
+
public SubForm1() { Text = "SubForm1"; ClientSize = new Size(300, 200); }
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
public class SubForm2 : Form
|
148
|
+
|
149
|
+
{
|
150
|
+
|
151
|
+
public SubForm2() { Text = "SubForm2"; ClientSize = new Size(300, 200); }
|
152
|
+
|
153
|
+
}
|
154
|
+
|
155
|
+
public class SubForm3 : Form
|
156
|
+
|
157
|
+
{
|
158
|
+
|
159
|
+
public SubForm3() { Text = "SubForm3"; ClientSize = new Size(300, 200); }
|
160
|
+
|
161
|
+
}
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
```
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
Form1.Designer.cs
|
170
|
+
|
171
|
+
```C#
|
172
|
+
|
173
|
+
namespace Questions293390
|
174
|
+
|
175
|
+
{
|
176
|
+
|
177
|
+
partial class Form1
|
178
|
+
|
179
|
+
{
|
180
|
+
|
181
|
+
/// <summary>
|
182
|
+
|
183
|
+
/// 必要なデザイナー変数です。
|
184
|
+
|
185
|
+
/// </summary>
|
186
|
+
|
187
|
+
private System.ComponentModel.IContainer components = null;
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
/// <summary>
|
192
|
+
|
193
|
+
/// 使用中のリソースをすべてクリーンアップします。
|
194
|
+
|
195
|
+
/// </summary>
|
196
|
+
|
197
|
+
/// <param name="disposing">マネージド リソースを破棄する場合は true を指定し、その他の場合は false を指定します。</param>
|
198
|
+
|
199
|
+
protected override void Dispose(bool disposing)
|
200
|
+
|
201
|
+
{
|
202
|
+
|
203
|
+
if(disposing && (components != null))
|
204
|
+
|
205
|
+
{
|
206
|
+
|
207
|
+
components.Dispose();
|
208
|
+
|
209
|
+
}
|
210
|
+
|
211
|
+
base.Dispose(disposing);
|
212
|
+
|
213
|
+
}
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
#region Windows フォーム デザイナーで生成されたコード
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
/// <summary>
|
222
|
+
|
223
|
+
/// デザイナー サポートに必要なメソッドです。このメソッドの内容を
|
224
|
+
|
225
|
+
/// コード エディターで変更しないでください。
|
226
|
+
|
227
|
+
/// </summary>
|
228
|
+
|
229
|
+
private void InitializeComponent()
|
230
|
+
|
231
|
+
{
|
232
|
+
|
233
|
+
this.button1 = new System.Windows.Forms.Button();
|
234
|
+
|
235
|
+
this.button2 = new System.Windows.Forms.Button();
|
236
|
+
|
237
|
+
this.button3 = new System.Windows.Forms.Button();
|
238
|
+
|
239
|
+
this.panel1 = new System.Windows.Forms.Panel();
|
240
|
+
|
241
|
+
this.otherButton = new System.Windows.Forms.Button();
|
242
|
+
|
243
|
+
this.label1 = new System.Windows.Forms.Label();
|
244
|
+
|
245
|
+
this.panel1.SuspendLayout();
|
246
|
+
|
247
|
+
this.SuspendLayout();
|
248
|
+
|
249
|
+
//
|
250
|
+
|
251
|
+
// button1
|
252
|
+
|
253
|
+
//
|
254
|
+
|
255
|
+
this.button1.Location = new System.Drawing.Point(5, 34);
|
256
|
+
|
257
|
+
this.button1.Name = "button1";
|
258
|
+
|
259
|
+
this.button1.Size = new System.Drawing.Size(75, 23);
|
260
|
+
|
261
|
+
this.button1.TabIndex = 0;
|
262
|
+
|
263
|
+
this.button1.Text = "button1";
|
264
|
+
|
265
|
+
this.button1.UseVisualStyleBackColor = true;
|
266
|
+
|
267
|
+
this.button1.Click += new System.EventHandler(this.button1_Click);
|
268
|
+
|
269
|
+
//
|
270
|
+
|
271
|
+
// button2
|
272
|
+
|
273
|
+
//
|
274
|
+
|
275
|
+
this.button2.Location = new System.Drawing.Point(5, 63);
|
276
|
+
|
277
|
+
this.button2.Name = "button2";
|
278
|
+
|
279
|
+
this.button2.Size = new System.Drawing.Size(75, 23);
|
280
|
+
|
281
|
+
this.button2.TabIndex = 1;
|
282
|
+
|
283
|
+
this.button2.Text = "button2";
|
284
|
+
|
285
|
+
this.button2.UseVisualStyleBackColor = true;
|
286
|
+
|
287
|
+
this.button2.Click += new System.EventHandler(this.button2_Click);
|
288
|
+
|
289
|
+
//
|
290
|
+
|
291
|
+
// button3
|
292
|
+
|
293
|
+
//
|
294
|
+
|
295
|
+
this.button3.Location = new System.Drawing.Point(5, 92);
|
296
|
+
|
297
|
+
this.button3.Name = "button3";
|
298
|
+
|
299
|
+
this.button3.Size = new System.Drawing.Size(75, 23);
|
300
|
+
|
301
|
+
this.button3.TabIndex = 2;
|
302
|
+
|
303
|
+
this.button3.Text = "button3";
|
304
|
+
|
305
|
+
this.button3.UseVisualStyleBackColor = true;
|
306
|
+
|
307
|
+
this.button3.Click += new System.EventHandler(this.button3_Click);
|
308
|
+
|
309
|
+
//
|
310
|
+
|
311
|
+
// panel1
|
312
|
+
|
313
|
+
//
|
314
|
+
|
315
|
+
this.panel1.Controls.Add(this.label1);
|
316
|
+
|
317
|
+
this.panel1.Controls.Add(this.button3);
|
318
|
+
|
319
|
+
this.panel1.Controls.Add(this.button1);
|
320
|
+
|
321
|
+
this.panel1.Controls.Add(this.button2);
|
322
|
+
|
323
|
+
this.panel1.Location = new System.Drawing.Point(153, 136);
|
324
|
+
|
325
|
+
this.panel1.Name = "panel1";
|
326
|
+
|
327
|
+
this.panel1.Size = new System.Drawing.Size(112, 125);
|
328
|
+
|
329
|
+
this.panel1.TabIndex = 3;
|
330
|
+
|
331
|
+
//
|
332
|
+
|
333
|
+
// otherButton
|
334
|
+
|
335
|
+
//
|
336
|
+
|
337
|
+
this.otherButton.Location = new System.Drawing.Point(538, 54);
|
338
|
+
|
339
|
+
this.otherButton.Name = "otherButton";
|
340
|
+
|
341
|
+
this.otherButton.Size = new System.Drawing.Size(75, 23);
|
342
|
+
|
343
|
+
this.otherButton.TabIndex = 4;
|
344
|
+
|
345
|
+
this.otherButton.Text = "otherButton";
|
346
|
+
|
347
|
+
this.otherButton.UseVisualStyleBackColor = true;
|
348
|
+
|
349
|
+
//
|
350
|
+
|
351
|
+
// label1
|
352
|
+
|
353
|
+
//
|
354
|
+
|
355
|
+
this.label1.AutoSize = true;
|
356
|
+
|
357
|
+
this.label1.Location = new System.Drawing.Point(3, 10);
|
358
|
+
|
359
|
+
this.label1.Name = "label1";
|
360
|
+
|
361
|
+
this.label1.Size = new System.Drawing.Size(35, 12);
|
362
|
+
|
363
|
+
this.label1.TabIndex = 3;
|
364
|
+
|
365
|
+
this.label1.Text = "label1";
|
366
|
+
|
367
|
+
//
|
368
|
+
|
369
|
+
// Form1
|
370
|
+
|
371
|
+
//
|
372
|
+
|
373
|
+
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
374
|
+
|
375
|
+
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
376
|
+
|
377
|
+
this.ClientSize = new System.Drawing.Size(800, 450);
|
378
|
+
|
379
|
+
this.Controls.Add(this.otherButton);
|
380
|
+
|
381
|
+
this.Controls.Add(this.panel1);
|
382
|
+
|
383
|
+
this.Name = "Form1";
|
384
|
+
|
385
|
+
this.Text = "Form1";
|
386
|
+
|
387
|
+
this.panel1.ResumeLayout(false);
|
388
|
+
|
389
|
+
this.panel1.PerformLayout();
|
390
|
+
|
391
|
+
this.ResumeLayout(false);
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
}
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
#endregion
|
400
|
+
|
401
|
+
private System.Windows.Forms.Label label1;
|
402
|
+
|
403
|
+
private System.Windows.Forms.Button otherButton;
|
404
|
+
|
405
|
+
private System.Windows.Forms.Button button1;
|
406
|
+
|
407
|
+
private System.Windows.Forms.Button button2;
|
408
|
+
|
409
|
+
private System.Windows.Forms.Button button3;
|
410
|
+
|
411
|
+
private System.Windows.Forms.Panel panel1;
|
412
|
+
|
413
|
+
}
|
414
|
+
|
415
|
+
}
|
416
|
+
|
417
|
+
```
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
Program.cs
|
422
|
+
|
423
|
+
```C#
|
424
|
+
|
425
|
+
using System;
|
426
|
+
|
427
|
+
using System.Windows.Forms;
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
namespace Questions293390
|
432
|
+
|
433
|
+
{
|
434
|
+
|
435
|
+
static class Program
|
436
|
+
|
437
|
+
{
|
438
|
+
|
439
|
+
[STAThread]
|
440
|
+
|
441
|
+
static void Main()
|
442
|
+
|
443
|
+
{
|
444
|
+
|
445
|
+
Application.EnableVisualStyles();
|
446
|
+
|
447
|
+
Application.SetCompatibleTextRenderingDefault(false);
|
448
|
+
|
449
|
+
Application.Run(Form1.Instance);
|
450
|
+
|
451
|
+
}
|
452
|
+
|
453
|
+
}
|
454
|
+
|
455
|
+
}
|
456
|
+
|
457
|
+
```
|