How to

create control and add to form on the fly

Published: 15. December 2008 | Updated: 15. December 2008
License: Microsoft Public License (MS-PL)
Categories: Winforms
Tags: C# Controls UI Winforms
Was this snippet helpful for you? YESYES / NONO
Get Analyzant!

Check your entire website from code to content in minutes with Analyzant, the free analysis suite.

Free download at analyzant.com

Snippet example shows how to create control and add to form on the fly

Code

// create control
Label control = new Label();

// set up
control.Text = "New Label";
control.Location = new Point(20, 40);
control.Size = new Size(100, 35);

// add to this form controls collection
this.Controls.Add(control);
Send us feedback about this snippet »



Related Snippets: