private void btnAdd_Click(object sender, EventArgs e) { Random rnd = new Random(); CheckBox ch = new CheckBox(); ch.AutoSize = true; ch.Location = new System.Drawing.Point(rnd.Next(20, Width), rnd.Next(20, Height)); ch.Size = new System.Drawing.Size(15, 14); ch.TabIndex = 1; ch.UseVisualStyleBackColor = true; ch.MouseDown += new MouseEventHandler(this.ChLeaf_MouseDown); Controls.Add(ch); Ant.Leafs = Ant.GetAllLeafs <CheckBox>(Controls); }
public Form1() { InitializeComponent(); Ant.Leafs = Ant.GetAllLeafs <CheckBox>(Controls); }