TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
How To Add Controls To Window Form At Run Time
Shreesh Raj
Jul 21
2016
Code
462
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Windows.Forms;
namespace
How_to_add_controls_dynamically {
public
partial
class
Form1: Form {
int
controlleft = 1;
public
Form1() {
InitializeComponent();
}
private
void
button1_Click(
object
sender, EventArgs e) {
TextBox txt =
new
TextBox();
this
.Controls.Add(txt);
txt.Top = controlleft * 25;
txt.Left = 100;
controlleft = controlleft + 1;
}
}
}
.net
Window Application
Controls
C#