fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9.  
  10. namespace WindowsFormsApplication1
  11. {
  12. public partial class Form1 : Form
  13. {
  14. public Form1()
  15. {
  16. InitializeComponent();
  17. }
  18. List<Label> labels = new List<Label>();
  19. private void Form1_Load(object sender, EventArgs e)
  20. {
  21.  
  22. }
  23.  
  24. private void Form1_Shown(object sender, EventArgs e)
  25. {
  26. for (int i = 0; i < 100; i++)
  27. {
  28. //ラベルの動的作成
  29. Label label = new Label();
  30. //Nameの設定
  31. label.Name = "label" + i.ToString();
  32. label.Text = "label" + i.ToString();
  33.  
  34. //動的に作成したLabelの細かい設定をここで
  35. label.AutoSize = true;
  36. label.Location = new Point(10, (i + 1) * 10);
  37.  
  38. //自分で管理するリストに追加
  39. //labels.Add(label);
  40. //Form1の配下に追加
  41. this.Controls.Add(label);
  42. }
  43. this.Invalidate();
  44. }
  45. }
  46. }
  47.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty