using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace XqMainFrame { public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void Form2_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { panel2.Controls.Clear(); int l = 30; int l1 = l + 1; long stime = DateTime.Now.Ticks; for (int i = 0; i < 30; i++) { for (int j = 0; j < 30; j++) { UserControl1 aa = new UserControl1(); aa.Size = new Size(l, l); aa.Location = new Point(i * l1, j * l1); panel2.Controls.Add(aa); } } long etime = DateTime.Now.Ticks; long diff = etime - stime; textBox1.Text = diff.ToString(); } private void button2_Click(object sender, EventArgs e) { panel2.Controls.Clear(); int l = 30; int l1 = l + 1; long stime = DateTime.Now.Ticks; for (int i = 0; i < 30; i++) { for (int j = 0; j < 30; j++) { TEntityControl aa = new TEntityControl(); aa.BackColor = Color.Blue; aa.Size = new Size(l, l); aa.Location = new Point(i * l1, j * l1); panel2.Controls.Add(aa); } } long etime = DateTime.Now.Ticks; long diff = etime - stime; textBox1.Text = diff.ToString(); } } }