回答編集履歴

5

不要なスペースを削除

2019/10/29 06:52

投稿

BluOxy
BluOxy

スコア2663

test CHANGED
@@ -20,7 +20,7 @@
20
20
 
21
21
  public FormMain (List<OtherFormValue> otherFormValues) {
22
22
 
23
- InitializeComponent ();
23
+ InitializeComponent();
24
24
 
25
25
  this.otherFormValues = otherFormValues;
26
26
 
@@ -32,7 +32,7 @@
32
32
 
33
33
  foreach (var otherFormValue in otherFormValues) {
34
34
 
35
- CheckBox c = new CheckBox ();
35
+ CheckBox c = new CheckBox();
36
36
 
37
37
  c.Checked = otherFormValue.Checked;
38
38
 
@@ -40,7 +40,7 @@
40
40
 
41
41
  //TODO:デザイナーでFlowLayoutPanelを配置すること
42
42
 
43
- flowLayoutPanel.Controls.Add (c);
43
+ flowLayoutPanel.Controls.Add(c);
44
44
 
45
45
  }
46
46
 

4

文章の修正

2019/10/29 06:52

投稿

BluOxy
BluOxy

スコア2663

test CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  また、縦に並べたい場合は`FlowLayoutPanel`を使ってください。
12
12
 
13
-
13
+ 下記はコードのイメージです。ビルドはしていません。
14
14
 
15
15
  ```C#
16
16
 

3

日本語の修正

2019/10/29 06:42

投稿

BluOxy
BluOxy

スコア2663

test CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
 
4
4
 
5
- Listの個数チェックボックスを配置するのは、デザイナーでは出来ないと思います。
5
+ Listのサイズチェックボックスを配置するのは、デザイナーでは出来ないと思います。
6
6
 
7
- そのフォームのロードイベントで動的にチェックボックスを追加するコーディングが必要す。
7
+ フォームのロードイベントで動的にチェックボックスを追加する処理を作る必要があります。
8
8
 
9
9
 
10
10
 

2

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

2019/10/29 06:35

投稿

BluOxy
BluOxy

スコア2663

test CHANGED
@@ -14,53 +14,47 @@
14
14
 
15
15
  ```C#
16
16
 
17
- public partial class FormMain : Form
17
+ public partial class FormMain : Form {
18
18
 
19
- {
19
+ private List<OtherFormValue> otherFormValues;
20
20
 
21
- private List<OtherFormValue> otherFormValues;
21
+ public FormMain (List<OtherFormValue> otherFormValues) {
22
22
 
23
- public FormMain(List<OtherFormValue> otherFormValues)
23
+ InitializeComponent ();
24
24
 
25
- {
25
+ this.otherFormValues = otherFormValues;
26
26
 
27
- InitializeComponent();
28
-
29
- this.otherFormValues = otherFormValues;
30
-
31
- }
27
+ }
32
28
 
33
29
 
34
30
 
35
-  private void FormMain_Load(object sender, EventArgs e)
31
+ private void FormMain_Load (object sender, EventArgs e) {
36
32
 
37
- {
33
+ foreach (var otherFormValue in otherFormValues) {
38
34
 
39
- foreach(var otherFormValue in otherFormValues){
35
+ CheckBox c = new CheckBox ();
40
36
 
41
- CheckBox c = new CheckBox();
37
+ c.Checked = otherFormValue.Checked;
42
38
 
43
- c.Checked = otherFormValue.Checked;
39
+ c.Text = otherFormValue.Type;
44
40
 
45
- c.Text = otherFormValue.Type;
41
+ //TODO:デザイナーでFlowLayoutPanelを配置すること
46
42
 
47
- //TODO:デザイナーでFlowLayoutPanelを配置すること
43
+ flowLayoutPanel.Controls.Add (c);
48
44
 
49
- flowLayoutPanel.Controls.Add(c);
45
+ }
50
46
 
51
47
  }
52
-
53
- }
54
48
 
55
49
  }
56
50
 
57
51
 
58
52
 
59
- public class OtherFormValue{
53
+ public class OtherFormValue {
60
54
 
61
- public string Type;
55
+ public string Type;
62
56
 
63
- public bool Checked;
57
+ public bool Checked;
64
58
 
65
59
  }
66
60
 
@@ -68,10 +62,14 @@
68
62
 
69
63
 
70
64
 
71
-
72
-
73
- 参考
65
+ ### 参考
74
66
 
75
67
  - [コントロールを実行時に作成する](https://dobon.net/vb/dotnet/control/addcontrol.html)
76
68
 
77
69
  - [FlowLayoutPanelコントロールを使って、コントロールを縦や横に整列させる](https://dobon.net/vb/dotnet/control/flbeginning.html)
70
+
71
+
72
+
73
+ ### 余談
74
+
75
+ Webフォームではなく、Windowsフォームではないでしょうか。

1

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

2019/10/29 06:30

投稿

BluOxy
BluOxy

スコア2663

test CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  Listの個数分をチェックボックスを配置するのは、デザイナーでは出来ないと思います。
6
6
 
7
- そのフォームのラクタで動的にチェックボックスを追加するコーディングが必要です。
7
+ そのフォームのロードイベントで動的にチェックボックスを追加するコーディングが必要です。
8
8
 
9
9
 
10
10
 
@@ -18,11 +18,23 @@
18
18
 
19
19
  {
20
20
 
21
+ private List<OtherFormValue> otherFormValues;
22
+
21
23
  public FormMain(List<OtherFormValue> otherFormValues)
22
24
 
23
25
  {
24
26
 
25
27
  InitializeComponent();
28
+
29
+ this.otherFormValues = otherFormValues;
30
+
31
+ }
32
+
33
+
34
+
35
+  private void FormMain_Load(object sender, EventArgs e)
36
+
37
+ {
26
38
 
27
39
  foreach(var otherFormValue in otherFormValues){
28
40