Windows Phone Developers

Wednesday, October 22, 2008

C# add controls to userform dynamically

Adding Controls to Windows Form using Code

Here is a simple way to add a button and position it on a Windows form through C# code.

Button btn = new Button();

btn.Text = "Sample Button";

btn.Left = 100;

btn.Top = 100;

this.Controls.Add(btn);

The output will look like the following






C# Controls.Add, Dynamic creation of Controls in .NET, Dynamic creation of Controls in C#, .NET Controls.Add, Create button on-the-fly using .Net (C#)

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

2 comments: