日期:2014-05-17 浏览次数:20846 次
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 WindowsFormsApplication6
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void SetCheckBox(GroupBox gb,Label lb)
{
lb.Text = lb.Text + "----" + gb.Location.X.ToString()+"/"+gb.Location.Y.ToString();
for (int a = gb.Location.Y + 12; a < gb.Location.Y + gb.Size.Height - 22; a = a + 22)
{
for (int b = gb.Location.X + 12; b < gb.Location.X + gb.Size.Width - 114; b = b + 112)
{
CheckBox cb = new CheckBox() { Text = "GB_" + b.ToString() + "_" + a.ToString(), Name = "GB_" + b.ToString() + "_" + a.ToString() };
cb.Location = new System.Drawing.Point(b, a);
cb.Size = new System.Drawing.Size(108, 16);
gb.Controls.Add(cb);
lb.Text = lb.Text + "----" + cb.Name;
}
}
}
private void Form1_Load(object sender, EventArgs e)
{
SetCheckBox(this.groupBox1,this.label1);
SetCheckBox(this.groupBox2, this.label2);
}
}
}