Search This Blog

Wednesday, October 8, 2014

Create form in runtime C#

C# > Windows > Form

A Form is a representation of any window displayed in your application.

Properties
Example

Create form in runtime

Form form1 = new Form();
Button button1 = new Button();
button1.Text = "OK";
button1.Location = new Point(5, 5);
form1.Text = "My Form";
form1.FormBorderStyle = FormBorderStyle.FixedDialog;
form1.MaximizeBox = false;
form1.MinimizeBox = false;
form1.StartPosition = FormStartPosition.CenterScreen;
form1.Controls.Add(button1);

form1.ShowDialog();