且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在c#.net Windows应用程序的groupbox控件内动态创建标签控件?

更新时间:2023-10-18 10:07:34

,您需要将标签添加到groupBox的控件集合中,而不是表单(调用this.controls.add withina方法int他的表单类会将其添加到表单控件集合中,因为在这种情况下,"this"就是表单)
you need to add your label to the groupBox''s control collection not the form''s (calling this.controls.add withina method int he form class will add it to the form control collection as, in that context, ''this'' is the form)


您必须将标签控件添加到GroupBox中.像这样

You have to add you lable control to GroupBox. Like this

GroupBox1.Controls.Add(lblobj);