Users Pricing

articles

home / developersection / articles / how to create controls at run time in csharp .net

How to create Controls at run time in CSharp .NET

Anonymous User 5899 27 Jul 2010 Updated 07 Sep 2019

 Here I’ve tried to demonstrate how to create controls at runtime in C#.Net. To create controls at runtime we have to create object of each control and add them to form.

Example
Adding text box to form
TextBox txt = new TextBox();
//creating object of TextBox.
 txt.Location = new System.Drawing.Point(100, 30);
//setting location
  txt.Width = 200;
//setting width
  this.Controls.Add(txt);
//adding text box to form
Adding label to form
 Label lbl = new Label();
//creating label object
  lbl.Text = "ID";
//setting text
  lbl.Location = new Point(20, 35);
//setting location
 this.Controls.Add(lbl);
//adding label to form.
 
 TextBox txt1 = new TextBox();
txt1.Location = new System.Drawing.Point(100, txt.Location.Y+txt.Height+10);
 txt1.Width = txt.Width;
 this.Controls.Add(txt1);
 
 Label lbl1 = new Label();
 lbl1.Text = "Name";
 lbl1.Location = new Point(20, txt1.Location.Y);
 this.Controls.Add(lbl1);
     
 Button btn = new Button();
 btn.Location = new System.Drawing.Point(txt1.Location.X+txt1.Width-btn.Width, txt1.Location.Y+txt1.Size.Height+5);
 btn.Text = "Click";
 this.Controls.Add(btn);
Screen Shot

How to create Controls at run time in CSharp .NET


<style>
<!--
 /* Font Definitions */
 @font-face
    {font-family:"Cambria Math";
    panose-1:2 4 5 3 5 4 6 3 2 4;
    mso-font-charset:0;
    mso-generic-font-family:roman;
    mso-font-pitch:variable;
    mso-font-signature:-1610611985 1107304683 0 0 415 0;}
@font-face
    {font-family:Cambria;
    panose-1:2 4 5 3 5 4 6 3 2 4;
    mso-font-charset:0;
    mso-generic-font-family:roman;
    mso-font-pitch:variable;
    mso-font-signature:-1610611985 1073741899 0 0 415 0;}
@font-face
    {font-family:Calibri;
    panose-1:2 15 5 2 2 2 4 3 2 4;
    mso-font-charset:0;
    mso-generic-font-family:swiss;
    mso-font-pitch:variable;
    mso-font-signature:-520092929 1073786111 9 0 415 0;}
@font-face
    {font-family:Tahoma;
    panose-1:2 11 6 4 3 5 4 4 2 4;
    mso-font-charset:0;
    mso-generic-font-family:swiss;
    mso-font-pitch:variable;
    mso-font-signature:-520081665 -1073717157 41 0 66047 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
    {mso-style-unhide:no;
    mso-style-qformat:yes;
    mso-style-parent:"";
    margin-top:0in;
    margin-right:0in;
    margin-bottom:10.0pt;
    margin-left:0in;
    line-height:115%;
    mso-pagination:widow-orphan;
    font-size:11.0pt;
    font-family:"Calibri","sans-serif";
    mso-ascii-font-family:Calibri;
    mso-ascii-theme-font:minor-latin;
    mso-fareast-font-family:Calibri;
    mso-fareast-theme-font:minor-latin;
    mso-hansi-font-family:Calibri;
    mso-hansi-theme-font:minor-latin;
    mso-bidi-font-family:"Times New Roman";
    mso-bidi-theme-font:minor-bidi;}
h1
    {mso-style-priority:9;
    mso-style-unhide:no;
    mso-style-qformat:yes;
    mso-style-link:"Heading 1 Char";
    mso-style-next:Normal;
    margin-top:24.0pt;
    margin-right:0in;
    margin-bottom:0in;
    margin-left:0in;
    margin-bottom:.0001pt;
    line-height:115%;
    mso-pagination:widow-orphan lines-together;
    page-break-after:avoid;
    mso-outline-level:1;
    font-size:14.0pt;
    font-family:"Cambria","serif";
    mso-ascii-font-family:Cambria;
    mso-ascii-theme-font:major-latin;
    mso-fareast-font-family:"Times New Roman";
    mso-fareast-theme-font:major-fareast;
    mso-hansi-font-family:Cambria;
    mso-hansi-theme-font:major-latin;
    mso-bidi-font-family:"Times New Roman";
    mso-bidi-theme-font:major-bidi;
    color:#365F91;
    mso-themecolor:accent1;
    mso-themeshade:191;
    mso-font-kerning:0pt;}
h2
    {mso-style-priority:9;
    mso-style-qformat:yes;
    mso-style-link:"Heading 2 Char";
    mso-style-next:Normal;
    margin-top:10.0pt;
    margin-right:0in;
    margin-bottom:0in;
    margin-left:0in;
    margin-bottom:.0001pt;
    line-height:115%;
    mso-pagination:widow-orphan lines-together;
    page-break-after:avoid;
    mso-outline-level:2;
    font-size:13.0pt;
    font-family:"Cambria","serif";
    mso-ascii-font-family:Cambria;
    mso-ascii-theme-font:major-latin;
    mso-fareast-font-family:"Times New Roman";
    mso-fareast-theme-font:major-fareast;
    mso-hansi-font-family:Cambria;
    mso-hansi-theme-font:major-latin;
    mso-bidi-font-family:"Times New Roman";
    mso-bidi-theme-font:major-bidi;
    color:#4F81BD;
    mso-themecolor:accent1;}
p.MsoTitle, li.MsoTitle, div.MsoTitle
    {mso-style-priority:10;
    mso-style-unhide:no;
    mso-style-qformat:yes;
    mso-style-link:"Title Char";
    mso-style-next:Normal;
    margin-top:0in;
    margin-right:0in;
    margin-bottom:15.0pt;
    margin-left:0in;
    mso-add-space:auto;
    mso-pagination:widow-orphan;
    border:none;
    mso-border-bottom-alt:solid #4F81BD 1.0pt;
    mso-border-bottom-themecolor:accent1;
    padding:0in;
    mso-padding-alt:0in 0in 4.0pt 0in;
    font-size:26.0pt;
    font-family:"Cambria","serif";
    mso-ascii-font-family:Cambria;
    mso-ascii-theme-font:major-latin;
    mso-fareast-font-family:"Times New Roman";
    mso-fareast-theme-font:major-fareast;
    mso-hansi-font-family:Cambria;
    mso-hansi-theme-font:major-latin;
    mso-bidi-font-family:"Times New Roman";
    mso-bidi-theme-font:major-bidi;
    color:#17365D;
    mso-themecolor:text2;
    mso-themeshade:191;
    letter-spacing:.25pt;
    mso-font-kerning:14.0pt;}
p.MsoTitleCxSpFirst, li.MsoTitleCxSpFirst, div.MsoTitleCxSpFirst
    {mso-style-priority:10;
    mso-style-unhide:no;
    mso-style-qformat:yes;
    mso-style-link:"Title Char";
    mso-style-next:Normal;
    mso-style-type:export-only;
    margin:0in;
    margin-bottom:.0001pt;
    mso-add-space:auto;
    mso-pagination:widow-orphan;
    border:none;
    mso-border-bottom-alt:solid #4F81BD 1.0pt;
    mso-border-bottom-themecolor:accent1;
    padding:0in;
    mso-padding-alt:0in 0in 4.0pt 0in;
    font-size:26.0pt;
    font-family:"Cambria","serif";
    mso-ascii-font-family:Cambria;
    mso-ascii-theme-font:major-latin;
    mso-fareast-font-family:"Times New Roman";
    mso-fareast-theme-font:major-fareast;
    mso-hansi-font-family:Cambria;
    mso-hansi-theme-font:major-latin;
    mso-bidi-font-family:"Times New Roman";
    mso-bidi-theme-font:major-bidi;
    color:#17365D;
    mso-themecolor:text2;
    mso-themeshade:191;
    letter-spacing:.25pt;
    mso-font-kerning:14.0pt;}
p.MsoTitleCxSpMiddle, li.MsoTitleCxSpMiddle, div.MsoTitleCxSpMiddle
    {mso-style-priority:10;
    mso-style-unhide:no;
    mso-style-qformat:yes;
    mso-style-link:"Title Char";
    mso-style-next:Normal;
    mso-style-type:export-only;
    margin:0in;
    margin-bottom:.0001pt;
    mso-add-space:auto;
    mso-pagination:widow-orphan;
    border:none;
    mso-border-bottom-alt:solid #4F81BD 1.0pt;
    mso-border-bottom-themecolor:accent1;
    padding:0in;
    mso-padding-alt:0in 0in 4.0pt 0in;
    font-size:26.0pt;
    font-family:"Cambria","serif";
    mso-ascii-font-family:Cambria;
    mso-ascii-theme-font:major-latin;
    mso-fareast-font-family:"Times New Roman";
    mso-fareast-theme-font:major-fareast;
    mso-hansi-font-family:Cambria;
    mso-hansi-theme-font:major-latin;
    mso-bidi-font-family:"Times New Roman";
    mso-bidi-theme-font:major-bidi;
    color:#17365D;
    mso-themecolor:text2;
    mso-themeshade:191;
    letter-spacing:.25pt;
    mso-font-kerning:14.0pt;}
p.MsoTitleCxSpLast, li.MsoTitleCxSpLast, div.MsoTitleCxSpLast
    {mso-style-priority:10;
    mso-style-unhide:no;
    mso-style-qformat:yes;
    mso-style-link:"Title Char";
    mso-style-next:Normal;
    mso-style-type:export-only;
    margin-top:0in;
    margin-right:0in;
    margin-bottom:15.0pt;
    margin-left:0in;
    mso-add-space:auto;
    mso-pagination:widow-orphan;
    border:none;
    mso-border-bottom-alt:solid #4F81BD 1.0pt;
    mso-border-bottom-themecolor:accent1;
    padding:0in;
    mso-padding-alt:0in 0in 4.0pt 0in;
    font-size:26.0pt;
    font-family:"Cambria","serif";
    mso-ascii-font-family:Cambria;
    mso-ascii-theme-font:major-latin;
    mso-fareast-font-family:"Times New Roman";
    mso-fareast-theme-font:major-fareast;
    mso-hansi-font-family:Cambria;
    mso-hansi-theme-font:major-latin;
    mso-bidi-font-family:"Times New Roman";
    mso-bidi-theme-font:major-bidi;
    color:#17365D;
    mso-themecolor:text2;
    mso-themeshade:191;
    letter-spacing:.25pt;
    mso-font-kerning:14.0pt;}
p.MsoSubtitle, li.MsoSubtitle, div.MsoSubtitle
    {mso-style-priority:11;
    mso-style-unhide:no;
    mso-style-qformat:yes;
    mso-style-link:"Subtitle Char";
    mso-style-next:Normal;
    margin-top:0in;
    margin-right:0in;
    margin-bottom:10.0pt;
    margin-left:0in;
    line-height:115%;
    mso-pagination:widow-orphan;
    font-size:12.0pt;
    font-family:"Cambria","serif";
    mso-ascii-font-family:Cambria;
    mso-ascii-theme-font:major-latin;
    mso-fareast-font-family:"Times New Roman";
    mso-fareast-theme-font:major-fareast;
    mso-hansi-font-family:Cambria;
    mso-hansi-theme-font:major-latin;
    mso-bidi-font-family:"Times New Roman";
    mso-bidi-theme-font:major-bidi;
    color:#4F81BD;
    mso-themecolor:accent1;
    letter-spacing:.75pt;
    font-style:italic;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
    {mso-style-noshow:yes;
    mso-style-priority:99;
    mso-style-link:"Balloon Text Char";
    margin:0in;
    margin-bottom:.0001pt;
    mso-pagination:widow-orphan;
    font-size:8.0pt;
    font-family:"Tahoma","sans-serif";
    mso-fareast-font-family:Calibri;
    mso-fareast-theme-font:minor-latin;}
span.TitleChar
    {mso-style-name:"Title Char";
    mso-style-priority:10;
    mso-style-unhide:no;
    mso-style-locked:yes;
    mso-style-link:Title;
    mso-ansi-font-size:26.0pt;
    mso-bidi-font-size:26.0pt;
    font-family:"Cambria","serif";
    mso-ascii-font-family:Cambria;
    mso-ascii-theme-font:major-latin;
    mso-fareast-font-family:"Times New Roman";
    mso-fareast-theme-font:major-fareast;
    mso-hansi-font-family:Cambria;
    mso-hansi-theme-font:major-latin;
    mso-bidi-font-family:"Times New Roman";
    mso-bidi-theme-font:major-bidi;
    color:#17365D;
    mso-themecolor:text2;
    mso-themeshade:191;
    letter-spacing:.25pt;
    mso-font-kerning:14.0pt;}
span.SubtitleChar
    {mso-style-name:"Subtitle Char";
    mso-style-priority:11;
    mso-style-unhide:no;
    mso-style-locked:yes;
    mso-style-link:Subtitle;
    mso-ansi-font-size:12.0pt;
    mso-bidi-font-size:12.0pt;
    font-family:"Cambria","serif";
    mso-ascii-font-family:Cambria;
    mso-ascii-theme-font:major-latin;
    mso-fareast-font-family:"Times New Roman";
    mso-fareast-theme-font:major-fareast;
    mso-hansi-font-family:Cambria;
    mso-hansi-theme-font:major-latin;
    mso-bidi-font-family:"Times New Roman";
    mso-bidi-theme-font:major-bidi;
    color:#4F81BD;
    mso-themecolor:accent1;
    letter-spacing:.75pt;
    font-style:italic;}
span.Heading2Char
    {mso-style-name:"Heading 2 Char";
    mso-style-priority:9;
    mso-style-unhide:no;
    mso-style-locked:yes;
    mso-style-link:"Heading 2";
    mso-ansi-font-size:13.0pt;
    mso-bidi-font-size:13.0pt;
    font-family:"Cambria","serif";
    mso-ascii-font-family:Cambria;
    mso-ascii-theme-font:major-latin;
    mso-fareast-font-family:"Times New Roman";
    mso-fareast-theme-font:major-fareast;
    mso-hansi-font-family:Cambria;
    mso-hansi-theme-font:major-latin;
    mso-bidi-font-family:"Times New Roman";
    mso-bidi-theme-font:major-bidi;
    color:#4F81BD;
    mso-themecolor:accent1;
    font-weight:bold;}
span.Heading1Char
    {mso-style-name:"Heading 1 Char";
    mso-style-priority:9;
    mso-style-unhide:no;
    mso-style-locked:yes;
    mso-style-link:"Heading 1";
    mso-ansi-font-size:14.0pt;
    mso-bidi-font-size:14.0pt;
    font-family:"Cambria","serif";
    mso-ascii-font-family:Cambria;
    mso-ascii-theme-font:major-latin;
    mso-fareast-font-family:"Times New Roman";
    mso-fareast-theme-font:major-fareast;
    mso-hansi-font-family:Cambria;
    mso-hansi-theme-font:major-latin;
    mso-bidi-font-family:"Times New Roman";
    mso-bidi-theme-font:major-bidi;
    color:#365F91;
    mso-themecolor:accent1;
    mso-themeshade:191;
    font-weight:bold;}
span.BalloonTextChar
    {mso-style-name:"Balloon Text Char";
    mso-style-noshow:yes;
    mso-style-priority:99;
    mso-style-unhide:no;
    mso-style-locked:yes;
    mso-style-link:"Balloon Text";
    mso-ansi-font-size:8.0pt;
    mso-bidi-font-size:8.0pt;
    font-family:"Tahoma","sans-serif";
    mso-ascii-font-family:Tahoma;
    mso-hansi-font-family:Tahoma;
    mso-bidi-font-family:Tahoma;}
.MsoChpDefault
    {mso-style-type:export-only;
    mso-default-props:yes;
    mso-ascii-font-family:Calibri;
    mso-ascii-theme-font:minor-latin;
    mso-fareast-font-family:Calibri;
    mso-fareast-theme-font:minor-latin;
    mso-hansi-font-family:Calibri;
    mso-hansi-theme-font:minor-latin;
    mso-bidi-font-family:"Times New Roman";
    mso-bidi-theme-font:minor-bidi;}
.MsoPapDefault
    {mso-style-type:export-only;
    margin-bottom:10.0pt;
    line-height:115%;}
@page WordSection1
    {size:8.5in 11.0in;
    margin:1.0in 1.0in 1.0in 1.0in;
    mso-header-margin:.5in;
    mso-footer-margin:.5in;
    mso-paper-source:0;}
div.WordSection1
    {page:WordSection1;}
-->
</style>
<!--[if gte mso 10]>
<style>
 /* Style Definitions */
 table.MsoNormalTable
    {mso-style-name:"Table Normal";
    mso-tstyle-rowband-size:0;
    mso-tstyle-colband-size:0;
    mso-style-noshow:yes;
    mso-style-priority:99;
    mso-style-qformat:yes;
    mso-style-parent:"";
    mso-padding-alt:0in 5.4pt 0in 5.4pt;
    mso-para-margin-top:0in;
    mso-para-margin-right:0in;
    mso-para-margin-bottom:10.0pt;
    mso-para-margin-left:0in;
    line-height:115%;
    mso-pagination:widow-orphan;
    font-size:11.0pt;
    font-family:"Calibri","sans-serif";
    mso-ascii-font-family:Calibri;
    mso-ascii-theme-font:minor-latin;
    mso-hansi-font-family:Calibri;
    mso-hansi-theme-font:minor-latin;
    mso-bidi-font-family:"Times New Roman";
    mso-bidi-theme-font:minor-bidi;}
</style>
<![endif]--><!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="3074"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1"/>
 </o:shapelayout></xml><![endif]-->
</asp:Content>
   
  <asp:content ID="Content1" ContentPlaceHolderID="content" runat="Server">
<div class=WordSection1>
<div style='mso-element:para-border-div;border:none;border-bottom:solid #4F81BD 1.0pt;
mso-border-bottom-themecolor:accent1;padding:0in 0in 4.0pt 0in'>
<p class=MsoTitle>How to create Controls at run time in C#.Net</p>
</div>
<p class=MsoNormal>Here I’ve tried to demonstrate how to create controls at
runtime in C#.Net. To create controls at runtime we have to create object of
each control and add them to form.</p>
<p class=MsoSubtitle>Example</p>
<h2>Adding text box to form</h2>
<p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in;
margin-left:.5in;margin-bottom:.0001pt;text-indent:.5in;line-height:normal;
mso-layout-grid-align:none;text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:#2B91AF;mso-no-proof:yes'>TextBox</span><span
style='font-size:10.0pt;font-family:"Courier New";mso-no-proof:yes'> txt = <span
style='color:blue'>new</span> <span style='color:#2B91AF'>TextBox</span>();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;line-height:115%;font-family:
"Courier New";color:#00B050;mso-no-proof:yes'>//creating object of TextBox.<o:p></o:p></span></p>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'><span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'><span
style='mso-spacerun:yes'>            </span>txt.Location = <span
style='color:blue'>new</span> System.Drawing.<span style='color:#2B91AF'>Point</span>(100,
30);<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;line-height:115%;font-family:
"Courier New";color:#00B050;mso-no-proof:yes'>//setting location<o:p></o:p></span></p>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'><span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'><span
style='mso-spacerun:yes'>            </span>txt.Width = 200;<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;line-height:115%;font-family:
"Courier New";color:#00B050;mso-no-proof:yes'>//setting width<o:p></o:p></span></p>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'><span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'><span
style='mso-spacerun:yes'>            </span><span style='color:blue'>this</span>.Controls.Add(txt);<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;line-height:115%;font-family:
"Courier New";color:#00B050;mso-no-proof:yes'>//adding text box to form<o:p></o:p></span></p>
<h2><span style='mso-no-proof:yes'>Adding label to form<o:p></o:p></span></h2>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'><span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'><span
style='mso-spacerun:yes'>            </span><span style='color:#2B91AF'>Label</span>
lbl = <span style='color:blue'>new</span> <span style='color:#2B91AF'>Label</span>();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;line-height:115%;font-family:
"Courier New";color:#00B050;mso-no-proof:yes'>//creating label object<o:p></o:p></span></p>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'><span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'><span
style='mso-spacerun:yes'>            </span>lbl.Text = <span style='color:#A31515'>&quot;ID&quot;</span>;<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;line-height:115%;font-family:
"Courier New";color:#00B050;mso-no-proof:yes'>//setting text<o:p></o:p></span></p>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'><span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'><span
style='mso-spacerun:yes'>            </span>lbl.Location = <span
style='color:blue'>new</span> <span style='color:#2B91AF'>Point</span>(20, 35);<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;line-height:115%;font-family:
"Courier New";color:#00B050;mso-no-proof:yes'>//setting location<o:p></o:p></span></p>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'><span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'><span
style='mso-spacerun:yes'>            </span><span style='color:blue'>this</span>.Controls.Add(lbl);<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;line-height:115%;font-family:
"Courier New";color:#00B050;mso-no-proof:yes'>//adding label to form.<o:p></o:p></span></p>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'><span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'><o:p>&nbsp;</o:p></span></p>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'><span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'><span
style='mso-spacerun:yes'>            </span><span style='color:#2B91AF'>TextBox</span>
txt1 = <span style='color:blue'>new</span> <span style='color:#2B91AF'>TextBox</span>();<o:p></o:p></span></p>
<p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in;
margin-left:1.0in;margin-bottom:.0001pt;line-height:normal;mso-layout-grid-align:
none;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";
mso-no-proof:yes'>txt1.Location = <span style='color:blue'>new</span>
System.Drawing.<span style='color:#2B91AF'>Point</span>(100,
txt.Location.Y+txt.Height+10);<o:p></o:p></span></p>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'><span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'><span
style='mso-spacerun:yes'>            </span>txt1.Width = txt.Width;<o:p></o:p></span></p>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'><span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'><span
style='mso-spacerun:yes'>            </span><span style='color:blue'>this</span>.Controls.Add(txt1);<o:p></o:p></span></p>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'><span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'><o:p>&nbsp;</o:p></span></p>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'><span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'><span
style='mso-spacerun:yes'>            </span><span style='color:#2B91AF'>Label</span>
lbl1 = <span style='color:blue'>new</span> <span style='color:#2B91AF'>Label</span>();<o:p></o:p></span></p>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'><span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'><span
style='mso-spacerun:yes'>            </span>lbl1.Text = <span style='color:
#A31515'>&quot;Name&quot;</span>;<o:p></o:p></span></p>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'><span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'><span
style='mso-spacerun:yes'>            </span>lbl1.Location = <span
style='color:blue'>new</span> <span style='color:#2B91AF'>Point</span>(20,
txt1.Location.Y);<o:p></o:p></span></p>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'><span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'><span
style='mso-spacerun:yes'>            </span><span style='color:blue'>this</span>.Controls.Add(lbl1);<o:p></o:p></span></p>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'><span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'><span
style='mso-spacerun:yes'>      </span><o:p></o:p></span></p>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'><span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'><span
style='mso-spacerun:yes'>            </span><span style='color:#2B91AF'>Button</span>
btn = <span style='color:blue'>new</span> <span style='color:#2B91AF'>Button</span>();<o:p></o:p></span></p>
<p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in;
margin-left:1.0in;margin-bottom:.0001pt;line-height:normal;mso-layout-grid-align:
none;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";
mso-no-proof:yes'>btn.Location = <span style='color:blue'>new</span>
System.Drawing.<span style='color:#2B91AF'>Point</span>(txt1.Location.X+txt1.Width-btn.Width,
txt1.Location.Y+txt1.Size.Height+5);<o:p></o:p></span></p>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;mso-layout-grid-align:none;text-autospace:none'><span style='font-size:
10.0pt;font-family:"Courier New";mso-no-proof:yes'><span
style='mso-spacerun:yes'>            </span>btn.Text = <span style='color:#A31515'>&quot;Click&quot;</span>;<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;line-height:115%;font-family:
"Courier New";mso-no-proof:yes'><span style='mso-spacerun:yes'>          
</span><span style='color:blue'>this</span>.Controls.Add(btn);<o:p></o:p></span></p>
<h1><span style='mso-no-proof:yes'>Screen Shot<o:p></o:p></span></h1>
<p class=MsoNormal><img src="Images/image002.jpg" /> </p>
</div>
 </asp:content>

I am a content writter !


2 Comments