回答編集履歴
3
見直しキャンペーン中
answer
CHANGED
@@ -1,238 +1,235 @@
|
|
1
|
-
`Application.Run(Form1.GetInstance());`
|
2
|
-
こうしてください。
|
3
|
-
|
4
|
-
---
|
5
|
-
|
6
|
-
今の状況というか問題点は、
|
7
|
-
1. メインフォームとサブフォーム1-13は既にできていて、動作自体に問題はない
|
8
|
-
2. サブフォームを排他的(どれか一つだけしか開けないよう)に改造しようとしている
|
9
|
-
3. その際地道にやれば(コメントアウトのコード)できることはわかっている
|
10
|
-
4. しかし13個はだるいし、もっといい方法がありそうに思える
|
11
|
-
|
12
|
-
ってことですよね?(実際2個目くらいでもうだるかったです^^;
|
13
|
-
|
14
|
-
自分だったらこうするかなぁ?ってコードです。
|
15
|
-
`button1_Click`もまとめてもよさそうですが、行数も減りそうにないのでそのまま。
|
16
|
-
|
17
|
-
Form1.cs
|
18
|
-
|
19
|
-
using System;
|
20
|
-
using System.
|
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
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
subForm.
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
//
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
{
|
98
|
-
|
99
|
-
|
100
|
-
/// <summary>
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
/// <summary>
|
106
|
-
///
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
///
|
121
|
-
///
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
this.
|
127
|
-
this.
|
128
|
-
this.
|
129
|
-
this.
|
130
|
-
this.
|
131
|
-
this.
|
132
|
-
|
133
|
-
|
134
|
-
//
|
135
|
-
|
136
|
-
|
137
|
-
this.button1.
|
138
|
-
this.button1.
|
139
|
-
this.button1.
|
140
|
-
this.button1.
|
141
|
-
this.button1.
|
142
|
-
|
143
|
-
|
144
|
-
//
|
145
|
-
|
146
|
-
|
147
|
-
this.button2.
|
148
|
-
this.button2.
|
149
|
-
this.button2.
|
150
|
-
this.button2.
|
151
|
-
this.button2.
|
152
|
-
|
153
|
-
|
154
|
-
//
|
155
|
-
|
156
|
-
|
157
|
-
this.button3.
|
158
|
-
this.button3.
|
159
|
-
this.button3.
|
160
|
-
this.button3.
|
161
|
-
this.button3.
|
162
|
-
|
163
|
-
|
164
|
-
//
|
165
|
-
|
166
|
-
|
167
|
-
this.panel1.Controls.Add(this.
|
168
|
-
this.panel1.Controls.Add(this.
|
169
|
-
this.panel1.
|
170
|
-
this.panel1.
|
171
|
-
this.panel1.
|
172
|
-
this.panel1.
|
173
|
-
|
174
|
-
|
175
|
-
//
|
176
|
-
|
177
|
-
|
178
|
-
this.otherButton.
|
179
|
-
this.otherButton.
|
180
|
-
this.otherButton.
|
181
|
-
this.otherButton.
|
182
|
-
|
183
|
-
|
184
|
-
//
|
185
|
-
|
186
|
-
|
187
|
-
this.label1.
|
188
|
-
this.label1.
|
189
|
-
this.label1.
|
190
|
-
this.label1.
|
191
|
-
|
192
|
-
|
193
|
-
//
|
194
|
-
|
195
|
-
|
196
|
-
this.
|
197
|
-
this.
|
198
|
-
this.
|
199
|
-
this.
|
200
|
-
this.
|
201
|
-
this.
|
202
|
-
this.
|
203
|
-
this.
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
private System.Windows.Forms.
|
211
|
-
private System.Windows.Forms.Button
|
212
|
-
private System.Windows.Forms.Button
|
213
|
-
private System.Windows.Forms.
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
```
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
}
|
236
|
-
}
|
237
|
-
}
|
1
|
+
`Application.Run(Form1.GetInstance());`
|
2
|
+
こうしてください。
|
3
|
+
|
4
|
+
---
|
5
|
+
|
6
|
+
今の状況というか問題点は、
|
7
|
+
1. メインフォームとサブフォーム1-13は既にできていて、動作自体に問題はない
|
8
|
+
2. サブフォームを排他的(どれか一つだけしか開けないよう)に改造しようとしている
|
9
|
+
3. その際地道にやれば(コメントアウトのコード)できることはわかっている
|
10
|
+
4. しかし13個はだるいし、もっといい方法がありそうに思える
|
11
|
+
|
12
|
+
ってことですよね?(実際2個目くらいでもうだるかったです^^;
|
13
|
+
|
14
|
+
自分だったらこうするかなぁ?ってコードです。
|
15
|
+
`button1_Click`もまとめてもよさそうですが、行数も減りそうにないのでそのまま。
|
16
|
+
|
17
|
+
```cs:Form1.cs
|
18
|
+
using System;
|
19
|
+
using System.Drawing;
|
20
|
+
using System.Windows.Forms;
|
21
|
+
|
22
|
+
namespace Questions293390
|
23
|
+
{
|
24
|
+
public partial class Form1 : Form
|
25
|
+
{
|
26
|
+
// シングルトンの必要はないかもしれないが、どうせSubFormからForm1をいじりたくなりますよね?
|
27
|
+
public static Form1 Instance { get; } = new Form1();
|
28
|
+
|
29
|
+
private Form1() => InitializeComponent();
|
30
|
+
|
31
|
+
private void button1_Click(object sender, EventArgs e)
|
32
|
+
=> ShowSubForm(new SubForm1(), panel1);
|
33
|
+
|
34
|
+
private void button2_Click(object sender, EventArgs e)
|
35
|
+
=> ShowSubForm(new SubForm2(), panel1);
|
36
|
+
|
37
|
+
private void button3_Click(object sender, EventArgs e)
|
38
|
+
=> ShowSubForm(new SubForm3(), panel1);
|
39
|
+
|
40
|
+
// class Commonにあっても別に構わない
|
41
|
+
private static void ShowSubForm(Form subForm, Panel group)
|
42
|
+
{
|
43
|
+
// Panel配下のボタンを不活性
|
44
|
+
foreach(var control in group.Controls)
|
45
|
+
{
|
46
|
+
if(control is Button button)
|
47
|
+
button.Enabled = false;
|
48
|
+
}
|
49
|
+
|
50
|
+
// SubFormのクローズを購読
|
51
|
+
subForm.FormClosed += SubForm_FormClosed;
|
52
|
+
// PanelをTagに入れて覚えておく
|
53
|
+
subForm.Tag = group;
|
54
|
+
subForm.Show();
|
55
|
+
}
|
56
|
+
|
57
|
+
// クローズ時にPanel配下のボタンを戻す
|
58
|
+
private static void SubForm_FormClosed(object sender, FormClosedEventArgs e)
|
59
|
+
{
|
60
|
+
// senderはSubForm自身
|
61
|
+
if(sender is Form subForm)
|
62
|
+
{
|
63
|
+
// PanelをTagから取り出す
|
64
|
+
if(subForm.Tag is Panel group)
|
65
|
+
{
|
66
|
+
foreach(var control in group.Controls)
|
67
|
+
{
|
68
|
+
if(control is Button button)
|
69
|
+
button.Enabled = true;
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
// SubFormではFormClosed等のイベントを書く必要がなくて楽々という意味
|
77
|
+
// 実際は普通に作る
|
78
|
+
public class SubForm1 : Form
|
79
|
+
{
|
80
|
+
public SubForm1() { Text = "SubForm1"; ClientSize = new Size(300, 200); }
|
81
|
+
}
|
82
|
+
public class SubForm2 : Form
|
83
|
+
{
|
84
|
+
public SubForm2() { Text = "SubForm2"; ClientSize = new Size(300, 200); }
|
85
|
+
}
|
86
|
+
public class SubForm3 : Form
|
87
|
+
{
|
88
|
+
public SubForm3() { Text = "SubForm3"; ClientSize = new Size(300, 200); }
|
89
|
+
}
|
90
|
+
}
|
91
|
+
```
|
92
|
+
|
93
|
+
```cs:Form1.Designer.cs
|
94
|
+
namespace Questions293390
|
95
|
+
{
|
96
|
+
partial class Form1
|
97
|
+
{
|
98
|
+
/// <summary>
|
99
|
+
/// 必要なデザイナー変数です。
|
100
|
+
/// </summary>
|
101
|
+
private System.ComponentModel.IContainer components = null;
|
102
|
+
|
103
|
+
/// <summary>
|
104
|
+
/// 使用中のリソースをすべてクリーンアップします。
|
105
|
+
/// </summary>
|
106
|
+
/// <param name="disposing">マネージド リソースを破棄する場合は true を指定し、その他の場合は false を指定します。</param>
|
107
|
+
protected override void Dispose(bool disposing)
|
108
|
+
{
|
109
|
+
if(disposing && (components != null))
|
110
|
+
{
|
111
|
+
components.Dispose();
|
112
|
+
}
|
113
|
+
base.Dispose(disposing);
|
114
|
+
}
|
115
|
+
|
116
|
+
#region Windows フォーム デザイナーで生成されたコード
|
117
|
+
|
118
|
+
/// <summary>
|
119
|
+
/// デザイナー サポートに必要なメソッドです。このメソッドの内容を
|
120
|
+
/// コード エディターで変更しないでください。
|
121
|
+
/// </summary>
|
122
|
+
private void InitializeComponent()
|
123
|
+
{
|
124
|
+
this.button1 = new System.Windows.Forms.Button();
|
125
|
+
this.button2 = new System.Windows.Forms.Button();
|
126
|
+
this.button3 = new System.Windows.Forms.Button();
|
127
|
+
this.panel1 = new System.Windows.Forms.Panel();
|
128
|
+
this.otherButton = new System.Windows.Forms.Button();
|
129
|
+
this.label1 = new System.Windows.Forms.Label();
|
130
|
+
this.panel1.SuspendLayout();
|
131
|
+
this.SuspendLayout();
|
132
|
+
//
|
133
|
+
// button1
|
134
|
+
//
|
135
|
+
this.button1.Location = new System.Drawing.Point(5, 34);
|
136
|
+
this.button1.Name = "button1";
|
137
|
+
this.button1.Size = new System.Drawing.Size(75, 23);
|
138
|
+
this.button1.TabIndex = 0;
|
139
|
+
this.button1.Text = "button1";
|
140
|
+
this.button1.UseVisualStyleBackColor = true;
|
141
|
+
this.button1.Click += new System.EventHandler(this.button1_Click);
|
142
|
+
//
|
143
|
+
// button2
|
144
|
+
//
|
145
|
+
this.button2.Location = new System.Drawing.Point(5, 63);
|
146
|
+
this.button2.Name = "button2";
|
147
|
+
this.button2.Size = new System.Drawing.Size(75, 23);
|
148
|
+
this.button2.TabIndex = 1;
|
149
|
+
this.button2.Text = "button2";
|
150
|
+
this.button2.UseVisualStyleBackColor = true;
|
151
|
+
this.button2.Click += new System.EventHandler(this.button2_Click);
|
152
|
+
//
|
153
|
+
// button3
|
154
|
+
//
|
155
|
+
this.button3.Location = new System.Drawing.Point(5, 92);
|
156
|
+
this.button3.Name = "button3";
|
157
|
+
this.button3.Size = new System.Drawing.Size(75, 23);
|
158
|
+
this.button3.TabIndex = 2;
|
159
|
+
this.button3.Text = "button3";
|
160
|
+
this.button3.UseVisualStyleBackColor = true;
|
161
|
+
this.button3.Click += new System.EventHandler(this.button3_Click);
|
162
|
+
//
|
163
|
+
// panel1
|
164
|
+
//
|
165
|
+
this.panel1.Controls.Add(this.label1);
|
166
|
+
this.panel1.Controls.Add(this.button3);
|
167
|
+
this.panel1.Controls.Add(this.button1);
|
168
|
+
this.panel1.Controls.Add(this.button2);
|
169
|
+
this.panel1.Location = new System.Drawing.Point(153, 136);
|
170
|
+
this.panel1.Name = "panel1";
|
171
|
+
this.panel1.Size = new System.Drawing.Size(112, 125);
|
172
|
+
this.panel1.TabIndex = 3;
|
173
|
+
//
|
174
|
+
// otherButton
|
175
|
+
//
|
176
|
+
this.otherButton.Location = new System.Drawing.Point(538, 54);
|
177
|
+
this.otherButton.Name = "otherButton";
|
178
|
+
this.otherButton.Size = new System.Drawing.Size(75, 23);
|
179
|
+
this.otherButton.TabIndex = 4;
|
180
|
+
this.otherButton.Text = "otherButton";
|
181
|
+
this.otherButton.UseVisualStyleBackColor = true;
|
182
|
+
//
|
183
|
+
// label1
|
184
|
+
//
|
185
|
+
this.label1.AutoSize = true;
|
186
|
+
this.label1.Location = new System.Drawing.Point(3, 10);
|
187
|
+
this.label1.Name = "label1";
|
188
|
+
this.label1.Size = new System.Drawing.Size(35, 12);
|
189
|
+
this.label1.TabIndex = 3;
|
190
|
+
this.label1.Text = "label1";
|
191
|
+
//
|
192
|
+
// Form1
|
193
|
+
//
|
194
|
+
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
195
|
+
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
196
|
+
this.ClientSize = new System.Drawing.Size(800, 450);
|
197
|
+
this.Controls.Add(this.otherButton);
|
198
|
+
this.Controls.Add(this.panel1);
|
199
|
+
this.Name = "Form1";
|
200
|
+
this.Text = "Form1";
|
201
|
+
this.panel1.ResumeLayout(false);
|
202
|
+
this.panel1.PerformLayout();
|
203
|
+
this.ResumeLayout(false);
|
204
|
+
|
205
|
+
}
|
206
|
+
|
207
|
+
#endregion
|
208
|
+
private System.Windows.Forms.Label label1;
|
209
|
+
private System.Windows.Forms.Button otherButton;
|
210
|
+
private System.Windows.Forms.Button button1;
|
211
|
+
private System.Windows.Forms.Button button2;
|
212
|
+
private System.Windows.Forms.Button button3;
|
213
|
+
private System.Windows.Forms.Panel panel1;
|
214
|
+
}
|
215
|
+
}
|
216
|
+
```
|
217
|
+
|
218
|
+
```cs:Program.cs
|
219
|
+
using System;
|
220
|
+
using System.Windows.Forms;
|
221
|
+
|
222
|
+
namespace Questions293390
|
223
|
+
{
|
224
|
+
static class Program
|
225
|
+
{
|
226
|
+
[STAThread]
|
227
|
+
static void Main()
|
228
|
+
{
|
229
|
+
Application.EnableVisualStyles();
|
230
|
+
Application.SetCompatibleTextRenderingDefault(false);
|
231
|
+
Application.Run(Form1.Instance);
|
232
|
+
}
|
233
|
+
}
|
234
|
+
}
|
238
235
|
```
|
2
メソッド化
answer
CHANGED
@@ -41,25 +41,34 @@
|
|
41
41
|
// class Commonにあっても別に構わない
|
42
42
|
private static void ShowSubForm(Form subForm, Panel group)
|
43
43
|
{
|
44
|
-
//
|
44
|
+
// Panel配下のボタンを不活性
|
45
45
|
foreach(var control in group.Controls)
|
46
46
|
{
|
47
47
|
if(control is Button button)
|
48
48
|
button.Enabled = false;
|
49
49
|
}
|
50
50
|
|
51
|
+
// SubFormのクローズを購読
|
51
|
-
subForm.FormClosed +=
|
52
|
+
subForm.FormClosed += SubForm_FormClosed;
|
53
|
+
// PanelをTagに入れて覚えておく
|
54
|
+
subForm.Tag = group;
|
52
55
|
subForm.Show();
|
56
|
+
}
|
53
57
|
|
54
|
-
|
58
|
+
// クローズ時にPanel配下のボタンを戻す
|
55
|
-
|
59
|
+
private static void SubForm_FormClosed(object sender, FormClosedEventArgs e)
|
60
|
+
{
|
61
|
+
// senderはSubForm自身
|
62
|
+
if(sender is Form subForm)
|
56
63
|
{
|
64
|
+
// PanelをTagから取り出す
|
57
|
-
subForm.
|
65
|
+
if(subForm.Tag is Panel group)
|
58
|
-
|
59
|
-
foreach(var control in group.Controls)
|
60
66
|
{
|
67
|
+
foreach(var control in group.Controls)
|
68
|
+
{
|
61
|
-
|
69
|
+
if(control is Button button)
|
62
|
-
|
70
|
+
button.Enabled = true;
|
71
|
+
}
|
63
72
|
}
|
64
73
|
}
|
65
74
|
}
|
1
コード追記
answer
CHANGED
@@ -1,2 +1,229 @@
|
|
1
1
|
`Application.Run(Form1.GetInstance());`
|
2
|
-
こうしてください。
|
2
|
+
こうしてください。
|
3
|
+
|
4
|
+
---
|
5
|
+
|
6
|
+
今の状況というか問題点は、
|
7
|
+
1. メインフォームとサブフォーム1-13は既にできていて、動作自体に問題はない
|
8
|
+
2. サブフォームを排他的(どれか一つだけしか開けないよう)に改造しようとしている
|
9
|
+
3. その際地道にやれば(コメントアウトのコード)できることはわかっている
|
10
|
+
4. しかし13個はだるいし、もっといい方法がありそうに思える
|
11
|
+
|
12
|
+
ってことですよね?(実際2個目くらいでもうだるかったです^^;
|
13
|
+
|
14
|
+
自分だったらこうするかなぁ?ってコードです。
|
15
|
+
`button1_Click`もまとめてもよさそうですが、行数も減りそうにないのでそのまま。
|
16
|
+
|
17
|
+
Form1.cs
|
18
|
+
```C#
|
19
|
+
using System;
|
20
|
+
using System.Drawing;
|
21
|
+
using System.Windows.Forms;
|
22
|
+
|
23
|
+
namespace Questions293390
|
24
|
+
{
|
25
|
+
public partial class Form1 : Form
|
26
|
+
{
|
27
|
+
// シングルトンの必要はないかもしれないが、どうせSubFormからForm1をいじりたくなりますよね?
|
28
|
+
public static Form1 Instance { get; } = new Form1();
|
29
|
+
|
30
|
+
private Form1() => InitializeComponent();
|
31
|
+
|
32
|
+
private void button1_Click(object sender, EventArgs e)
|
33
|
+
=> ShowSubForm(new SubForm1(), panel1);
|
34
|
+
|
35
|
+
private void button2_Click(object sender, EventArgs e)
|
36
|
+
=> ShowSubForm(new SubForm2(), panel1);
|
37
|
+
|
38
|
+
private void button3_Click(object sender, EventArgs e)
|
39
|
+
=> ShowSubForm(new SubForm3(), panel1);
|
40
|
+
|
41
|
+
// class Commonにあっても別に構わない
|
42
|
+
private static void ShowSubForm(Form subForm, Panel group)
|
43
|
+
{
|
44
|
+
// group配下のボタンを不活性
|
45
|
+
foreach(var control in group.Controls)
|
46
|
+
{
|
47
|
+
if(control is Button button)
|
48
|
+
button.Enabled = false;
|
49
|
+
}
|
50
|
+
|
51
|
+
subForm.FormClosed += Closed;
|
52
|
+
subForm.Show();
|
53
|
+
|
54
|
+
// クローズ時にgroup配下のボタンを活性に戻す
|
55
|
+
void Closed(object sender, FormClosedEventArgs e)
|
56
|
+
{
|
57
|
+
subForm.FormClosed -= Closed;
|
58
|
+
|
59
|
+
foreach(var control in group.Controls)
|
60
|
+
{
|
61
|
+
if(control is Button button)
|
62
|
+
button.Enabled = true;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
// SubFormではFormClosed等のイベントを書く必要がなくて楽々という意味
|
69
|
+
// 実際は普通に作る
|
70
|
+
public class SubForm1 : Form
|
71
|
+
{
|
72
|
+
public SubForm1() { Text = "SubForm1"; ClientSize = new Size(300, 200); }
|
73
|
+
}
|
74
|
+
public class SubForm2 : Form
|
75
|
+
{
|
76
|
+
public SubForm2() { Text = "SubForm2"; ClientSize = new Size(300, 200); }
|
77
|
+
}
|
78
|
+
public class SubForm3 : Form
|
79
|
+
{
|
80
|
+
public SubForm3() { Text = "SubForm3"; ClientSize = new Size(300, 200); }
|
81
|
+
}
|
82
|
+
}
|
83
|
+
```
|
84
|
+
|
85
|
+
Form1.Designer.cs
|
86
|
+
```C#
|
87
|
+
namespace Questions293390
|
88
|
+
{
|
89
|
+
partial class Form1
|
90
|
+
{
|
91
|
+
/// <summary>
|
92
|
+
/// 必要なデザイナー変数です。
|
93
|
+
/// </summary>
|
94
|
+
private System.ComponentModel.IContainer components = null;
|
95
|
+
|
96
|
+
/// <summary>
|
97
|
+
/// 使用中のリソースをすべてクリーンアップします。
|
98
|
+
/// </summary>
|
99
|
+
/// <param name="disposing">マネージド リソースを破棄する場合は true を指定し、その他の場合は false を指定します。</param>
|
100
|
+
protected override void Dispose(bool disposing)
|
101
|
+
{
|
102
|
+
if(disposing && (components != null))
|
103
|
+
{
|
104
|
+
components.Dispose();
|
105
|
+
}
|
106
|
+
base.Dispose(disposing);
|
107
|
+
}
|
108
|
+
|
109
|
+
#region Windows フォーム デザイナーで生成されたコード
|
110
|
+
|
111
|
+
/// <summary>
|
112
|
+
/// デザイナー サポートに必要なメソッドです。このメソッドの内容を
|
113
|
+
/// コード エディターで変更しないでください。
|
114
|
+
/// </summary>
|
115
|
+
private void InitializeComponent()
|
116
|
+
{
|
117
|
+
this.button1 = new System.Windows.Forms.Button();
|
118
|
+
this.button2 = new System.Windows.Forms.Button();
|
119
|
+
this.button3 = new System.Windows.Forms.Button();
|
120
|
+
this.panel1 = new System.Windows.Forms.Panel();
|
121
|
+
this.otherButton = new System.Windows.Forms.Button();
|
122
|
+
this.label1 = new System.Windows.Forms.Label();
|
123
|
+
this.panel1.SuspendLayout();
|
124
|
+
this.SuspendLayout();
|
125
|
+
//
|
126
|
+
// button1
|
127
|
+
//
|
128
|
+
this.button1.Location = new System.Drawing.Point(5, 34);
|
129
|
+
this.button1.Name = "button1";
|
130
|
+
this.button1.Size = new System.Drawing.Size(75, 23);
|
131
|
+
this.button1.TabIndex = 0;
|
132
|
+
this.button1.Text = "button1";
|
133
|
+
this.button1.UseVisualStyleBackColor = true;
|
134
|
+
this.button1.Click += new System.EventHandler(this.button1_Click);
|
135
|
+
//
|
136
|
+
// button2
|
137
|
+
//
|
138
|
+
this.button2.Location = new System.Drawing.Point(5, 63);
|
139
|
+
this.button2.Name = "button2";
|
140
|
+
this.button2.Size = new System.Drawing.Size(75, 23);
|
141
|
+
this.button2.TabIndex = 1;
|
142
|
+
this.button2.Text = "button2";
|
143
|
+
this.button2.UseVisualStyleBackColor = true;
|
144
|
+
this.button2.Click += new System.EventHandler(this.button2_Click);
|
145
|
+
//
|
146
|
+
// button3
|
147
|
+
//
|
148
|
+
this.button3.Location = new System.Drawing.Point(5, 92);
|
149
|
+
this.button3.Name = "button3";
|
150
|
+
this.button3.Size = new System.Drawing.Size(75, 23);
|
151
|
+
this.button3.TabIndex = 2;
|
152
|
+
this.button3.Text = "button3";
|
153
|
+
this.button3.UseVisualStyleBackColor = true;
|
154
|
+
this.button3.Click += new System.EventHandler(this.button3_Click);
|
155
|
+
//
|
156
|
+
// panel1
|
157
|
+
//
|
158
|
+
this.panel1.Controls.Add(this.label1);
|
159
|
+
this.panel1.Controls.Add(this.button3);
|
160
|
+
this.panel1.Controls.Add(this.button1);
|
161
|
+
this.panel1.Controls.Add(this.button2);
|
162
|
+
this.panel1.Location = new System.Drawing.Point(153, 136);
|
163
|
+
this.panel1.Name = "panel1";
|
164
|
+
this.panel1.Size = new System.Drawing.Size(112, 125);
|
165
|
+
this.panel1.TabIndex = 3;
|
166
|
+
//
|
167
|
+
// otherButton
|
168
|
+
//
|
169
|
+
this.otherButton.Location = new System.Drawing.Point(538, 54);
|
170
|
+
this.otherButton.Name = "otherButton";
|
171
|
+
this.otherButton.Size = new System.Drawing.Size(75, 23);
|
172
|
+
this.otherButton.TabIndex = 4;
|
173
|
+
this.otherButton.Text = "otherButton";
|
174
|
+
this.otherButton.UseVisualStyleBackColor = true;
|
175
|
+
//
|
176
|
+
// label1
|
177
|
+
//
|
178
|
+
this.label1.AutoSize = true;
|
179
|
+
this.label1.Location = new System.Drawing.Point(3, 10);
|
180
|
+
this.label1.Name = "label1";
|
181
|
+
this.label1.Size = new System.Drawing.Size(35, 12);
|
182
|
+
this.label1.TabIndex = 3;
|
183
|
+
this.label1.Text = "label1";
|
184
|
+
//
|
185
|
+
// Form1
|
186
|
+
//
|
187
|
+
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
188
|
+
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
189
|
+
this.ClientSize = new System.Drawing.Size(800, 450);
|
190
|
+
this.Controls.Add(this.otherButton);
|
191
|
+
this.Controls.Add(this.panel1);
|
192
|
+
this.Name = "Form1";
|
193
|
+
this.Text = "Form1";
|
194
|
+
this.panel1.ResumeLayout(false);
|
195
|
+
this.panel1.PerformLayout();
|
196
|
+
this.ResumeLayout(false);
|
197
|
+
|
198
|
+
}
|
199
|
+
|
200
|
+
#endregion
|
201
|
+
private System.Windows.Forms.Label label1;
|
202
|
+
private System.Windows.Forms.Button otherButton;
|
203
|
+
private System.Windows.Forms.Button button1;
|
204
|
+
private System.Windows.Forms.Button button2;
|
205
|
+
private System.Windows.Forms.Button button3;
|
206
|
+
private System.Windows.Forms.Panel panel1;
|
207
|
+
}
|
208
|
+
}
|
209
|
+
```
|
210
|
+
|
211
|
+
Program.cs
|
212
|
+
```C#
|
213
|
+
using System;
|
214
|
+
using System.Windows.Forms;
|
215
|
+
|
216
|
+
namespace Questions293390
|
217
|
+
{
|
218
|
+
static class Program
|
219
|
+
{
|
220
|
+
[STAThread]
|
221
|
+
static void Main()
|
222
|
+
{
|
223
|
+
Application.EnableVisualStyles();
|
224
|
+
Application.SetCompatibleTextRenderingDefault(false);
|
225
|
+
Application.Run(Form1.Instance);
|
226
|
+
}
|
227
|
+
}
|
228
|
+
}
|
229
|
+
```
|