Sunday, September 12, 2010

C# Tutorial: Create a Control while the Program is running

This is the code

Button btn = new Button();

/////////// Button1_Click ////////////////
// Set the parent container of the button. In our case is the main form which is "this".
btn.Parent = this;
// The location where the button will be created.
btn.Location = new System.Drawing.Point(13, 81);
// The size of the button.
btn.Size = new System.Drawing.Size(60, 85);
// The Name of the button.
btn.Name = "btn1";
// The text that will appear on the button.
btn.Text = "My Button";

Or download the solution

No comments:

Post a Comment