I CALL 我又遇难了!Groupbox问题!

APOLLO_TS APOLLO_TS 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
页面就是两个groupbox,两个label

动态添加checkbox,结果就显示其中一个!到底哪个地方出问题了啊?


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);
}
}
}





第二个groupbox 怎么就没添加进去呢?坐标没重复,名称没重复。god!
...全文
评论 5
收藏 已收藏
分享
返回顶部
APOLLO_TS
C# 111,128 成员 642,537 内容