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#)
you didn't told where can we add this code.
ReplyDeletegud example
ReplyDelete