teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

5

不要なスペースを削除

2019/10/29 06:52

投稿

BluOxy
BluOxy

スコア2663

answer CHANGED
@@ -9,17 +9,17 @@
9
9
  public partial class FormMain : Form {
10
10
  private List<OtherFormValue> otherFormValues;
11
11
  public FormMain (List<OtherFormValue> otherFormValues) {
12
- InitializeComponent ();
12
+ InitializeComponent();
13
13
  this.otherFormValues = otherFormValues;
14
14
  }
15
15
 
16
16
  private void FormMain_Load (object sender, EventArgs e) {
17
17
  foreach (var otherFormValue in otherFormValues) {
18
- CheckBox c = new CheckBox ();
18
+ CheckBox c = new CheckBox();
19
19
  c.Checked = otherFormValue.Checked;
20
20
  c.Text = otherFormValue.Type;
21
21
  //TODO:デザイナーでFlowLayoutPanelを配置すること
22
- flowLayoutPanel.Controls.Add (c);
22
+ flowLayoutPanel.Controls.Add(c);
23
23
  }
24
24
  }
25
25
  }

4

文章の修正

2019/10/29 06:52

投稿

BluOxy
BluOxy

スコア2663

answer CHANGED
@@ -4,7 +4,7 @@
4
4
  フォームのロードイベントで動的にチェックボックスを追加する処理を作る必要があります。
5
5
 
6
6
  また、縦に並べたい場合は`FlowLayoutPanel`を使ってください。
7
-
7
+ 下記はコードのイメージです。ビルドはしていません。
8
8
  ```C#
9
9
  public partial class FormMain : Form {
10
10
  private List<OtherFormValue> otherFormValues;

3

日本語の修正

2019/10/29 06:42

投稿

BluOxy
BluOxy

スコア2663

answer CHANGED
@@ -1,7 +1,7 @@
1
1
  > 考えうるチェックボックス数をすべて配置する必要がありますか?
2
2
 
3
- Listの個数チェックボックスを配置するのは、デザイナーでは出来ないと思います。
3
+ Listのサイズチェックボックスを配置するのは、デザイナーでは出来ないと思います。
4
- そのフォームのロードイベントで動的にチェックボックスを追加するコーディングが必要す。
4
+ フォームのロードイベントで動的にチェックボックスを追加する処理を作る必要があります。
5
5
 
6
6
  また、縦に並べたい場合は`FlowLayoutPanel`を使ってください。
7
7
 

2

インデントをスペース2→4に訂正

2019/10/29 06:35

投稿

BluOxy
BluOxy

スコア2663

answer CHANGED
@@ -6,34 +6,33 @@
6
6
  また、縦に並べたい場合は`FlowLayoutPanel`を使ってください。
7
7
 
8
8
  ```C#
9
- public partial class FormMain : Form
9
+ public partial class FormMain : Form {
10
- {
11
- private List<OtherFormValue> otherFormValues;
10
+ private List<OtherFormValue> otherFormValues;
12
- public FormMain(List<OtherFormValue> otherFormValues)
11
+ public FormMain (List<OtherFormValue> otherFormValues) {
13
- {
14
- InitializeComponent();
12
+ InitializeComponent ();
15
- this.otherFormValues = otherFormValues;
13
+ this.otherFormValues = otherFormValues;
16
- }
14
+ }
17
15
 
18
-  private void FormMain_Load(object sender, EventArgs e)
16
+ private void FormMain_Load (object sender, EventArgs e) {
19
- {
20
- foreach(var otherFormValue in otherFormValues){
17
+ foreach (var otherFormValue in otherFormValues) {
21
- CheckBox c = new CheckBox();
18
+ CheckBox c = new CheckBox ();
22
- c.Checked = otherFormValue.Checked;
19
+ c.Checked = otherFormValue.Checked;
23
- c.Text = otherFormValue.Type;
20
+ c.Text = otherFormValue.Type;
24
- //TODO:デザイナーでFlowLayoutPanelを配置すること
21
+ //TODO:デザイナーでFlowLayoutPanelを配置すること
25
- flowLayoutPanel.Controls.Add(c);
22
+ flowLayoutPanel.Controls.Add (c);
23
+ }
26
24
  }
27
- }
28
25
  }
29
26
 
30
- public class OtherFormValue{
27
+ public class OtherFormValue {
31
- public string Type;
28
+ public string Type;
32
- public bool Checked;
29
+ public bool Checked;
33
30
  }
34
31
  ```
35
32
 
33
+ ### 参考
34
+ - [コントロールを実行時に作成する](https://dobon.net/vb/dotnet/control/addcontrol.html)
35
+ - [FlowLayoutPanelコントロールを使って、コントロールを縦や横に整列させる](https://dobon.net/vb/dotnet/control/flbeginning.html)
36
36
 
37
- 参考
37
+ ### 余談
38
- - [コントロルを実行時に作成する](https://dobon.net/vb/dotnet/control/addcontrol.html)
38
+ Webフォムではなく、Windowsフォームではないでしょうか。
39
- - [FlowLayoutPanelコントロールを使って、コントロールを縦や横に整列させる](https://dobon.net/vb/dotnet/control/flbeginning.html)

1

ロードイベントでコントロールを作る用に修正

2019/10/29 06:30

投稿

BluOxy
BluOxy

スコア2663

answer CHANGED
@@ -1,16 +1,22 @@
1
1
  > 考えうるチェックボックス数をすべて配置する必要がありますか?
2
2
 
3
3
  Listの個数分をチェックボックスを配置するのは、デザイナーでは出来ないと思います。
4
- そのフォームのラクタで動的にチェックボックスを追加するコーディングが必要です。
4
+ そのフォームのロードイベントで動的にチェックボックスを追加するコーディングが必要です。
5
5
 
6
6
  また、縦に並べたい場合は`FlowLayoutPanel`を使ってください。
7
7
 
8
8
  ```C#
9
9
  public partial class FormMain : Form
10
10
  {
11
+ private List<OtherFormValue> otherFormValues;
11
12
  public FormMain(List<OtherFormValue> otherFormValues)
12
13
  {
13
14
  InitializeComponent();
15
+ this.otherFormValues = otherFormValues;
16
+ }
17
+
18
+  private void FormMain_Load(object sender, EventArgs e)
19
+ {
14
20
  foreach(var otherFormValue in otherFormValues){
15
21
  CheckBox c = new CheckBox();
16
22
  c.Checked = otherFormValue.Checked;