using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//List<Label> labels = new List<Label>();
private void Form1_Load(object sender, EventArgs e)
{
}
private void Form1_Shown(object sender, EventArgs e)
{
for (int i = 0; i < 100; i++)
{
//ラベルの動的作成
Label label = new Label();
//Nameの設定
label.Name = "label" + i.ToString();
label.Text = "label" + i.ToString();
//動的に作成したLabelの細かい設定をここで
label.AutoSize = true;
label.Location = new Point(10, (i + 1) * 10);
//自分で管理するリストに追加
//labels.Add(label);
//Form1の配下に追加
this.Controls.Add(label);
}
//文字列で検索してアクセス可能だけどこんな面倒なことするの?
((Label)(this.Controls["label10"])).Text = "hoge";
this.Invalidate();
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYzsKdXNpbmcgU3lzdGVtLkNvbXBvbmVudE1vZGVsOwp1c2luZyBTeXN0ZW0uRGF0YTsKdXNpbmcgU3lzdGVtLkRyYXdpbmc7CnVzaW5nIFN5c3RlbS5MaW5xOwp1c2luZyBTeXN0ZW0uVGV4dDsKdXNpbmcgU3lzdGVtLldpbmRvd3MuRm9ybXM7CgpuYW1lc3BhY2UgV2luZG93c0Zvcm1zQXBwbGljYXRpb24xCnsKICAgIHB1YmxpYyBwYXJ0aWFsIGNsYXNzIEZvcm0xIDogRm9ybQogICAgewogICAgICAgIHB1YmxpYyBGb3JtMSgpCiAgICAgICAgewogICAgICAgICAgICBJbml0aWFsaXplQ29tcG9uZW50KCk7CiAgICAgICAgfQogICAgICAgIC8vTGlzdDxMYWJlbD4gbGFiZWxzID0gbmV3IExpc3Q8TGFiZWw+KCk7CiAgICAgICAgcHJpdmF0ZSB2b2lkIEZvcm0xX0xvYWQob2JqZWN0IHNlbmRlciwgRXZlbnRBcmdzIGUpCiAgICAgICAgewoKICAgICAgICB9CgogICAgICAgIHByaXZhdGUgdm9pZCBGb3JtMV9TaG93bihvYmplY3Qgc2VuZGVyLCBFdmVudEFyZ3MgZSkKICAgICAgICB7CiAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgMTAwOyBpKyspCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIC8v44Op44OZ44Or44Gu5YuV55qE5L2c5oiQCiAgICAgICAgICAgICAgICBMYWJlbCBsYWJlbCA9IG5ldyBMYWJlbCgpOwogICAgICAgICAgICAgICAgLy9OYW1l44Gu6Kit5a6aCiAgICAgICAgICAgICAgICBsYWJlbC5OYW1lID0gImxhYmVsIiArIGkuVG9TdHJpbmcoKTsKICAgICAgICAgICAgICAgIGxhYmVsLlRleHQgPSAibGFiZWwiICsgaS5Ub1N0cmluZygpOwoKICAgICAgICAgICAgICAgIC8v5YuV55qE44Gr5L2c5oiQ44GX44GfTGFiZWzjga7ntLDjgYvjgYToqK3lrprjgpLjgZPjgZPjgacKICAgICAgICAgICAgICAgIGxhYmVsLkF1dG9TaXplID0gdHJ1ZTsKICAgICAgICAgICAgICAgIGxhYmVsLkxvY2F0aW9uID0gbmV3IFBvaW50KDEwLCAoaSArIDEpICogMTApOwoKICAgICAgICAgICAgICAgIC8v6Ieq5YiG44Gn566h55CG44GZ44KL44Oq44K544OI44Gr6L+95YqgCiAgICAgICAgICAgICAgICAvL2xhYmVscy5BZGQobGFiZWwpOwogICAgICAgICAgICAgICAgLy9Gb3JtMeOBrumFjeS4i+OBq+i/veWKoAogICAgICAgICAgICAgICAgdGhpcy5Db250cm9scy5BZGQobGFiZWwpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIC8v5paH5a2X5YiX44Gn5qSc57Si44GX44Gm44Ki44Kv44K744K55Y+v6IO944Gg44GR44Gp44GT44KT44Gq6Z2i5YCS44Gq44GT44Go44GZ44KL44Gu77yfCiAgICAgICAgICAgICgoTGFiZWwpKHRoaXMuQ29udHJvbHNbImxhYmVsMTAiXSkpLlRleHQgPSAiaG9nZSI7CiAgICAgICAgICAgIHRoaXMuSW52YWxpZGF0ZSgpOwogICAgICAgIH0KICAgIH0KfQo=