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

回答編集履歴

1

追記

2019/04/03 14:13

投稿

YAmaGNZ
YAmaGNZ

スコア10674

answer CHANGED
@@ -1,2 +1,32 @@
1
1
  LabelのAutoSizeプロパティは初期値でtrueだったかと思います。
2
- Textプロパティを設定していないので、見えないだけじゃないですか?
2
+ Textプロパティを設定していないので、見えないだけじゃないですか?
3
+
4
+ ```C#
5
+ RadioButton[] radiobutton = new RadioButton[6];
6
+ Label[] label = new Label[7];
7
+ private void Form1_Load(object sender, EventArgs e)
8
+ {
9
+ int i;
10
+ for (i = 0; i < 6; i++)
11
+ {
12
+ radiobutton[i] = new RadioButton();         //ラジオオブジェクトを作成する
13
+ radiobutton[i].Left = 0;               //左辺の座標を指定する
14
+ radiobutton[i].Top = radiobutton[0].Height * i;  //上辺の座標を指定する
15
+ radiobutton[i].Tag = i;               //Tagを指定する
16
+ Controls.Add(radiobutton[i]);            //コントロールを登録する
17
+ }
18
+
19
+ for (i = 0; i < 7; i++)
20
+ {
21
+ label[i] = new Label();               //ラベルオブジェクトを作成する
22
+ label[i].Left = radiobutton[0].Width;     //左辺の座標を指定する
23
+ label[i].Top = label[0].Height * i;        //上辺の座標を指定する
24
+ label[i].Tag = i;                  //Tagを指定する
25
+ label[i].Text = $"test{i}";
26
+ Controls.Add(label[i]);              //コントロールを登録する
27
+ }
28
+ }
29
+
30
+ ```
31
+ これでラベルが表示されているのを確認しています。
32
+ 元のソースから、Leftの値とTextプロパティを変えただけです。