开发者

Create a new conrol after program running C#

For example,I click button and then on the form appears GroupBox with some controls inside.One more click-one more开发者_StackOverflow GroupBox.This may lasts to infinity.Please,tell me how to do that???


You can create a new control and add it to the group you want to:

Your_Control ctl = new Your_Control();

Your_Parent_Control.Controls.Add(ctl);

Link to Control Class:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.aspx

Link to the controls property:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.controls.aspx


You can create controls in code just like any other object. Looks something like this.

GroupBox box = new GroupBox();
this.Controls.Add(box);    // assuming "this" is your parent form

You can add controls to your group box in the same way. All Control objects have a Controls collection for child controls. Although it doesn't really make sense for some of them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜