Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Creating a textbox dynamically!!!

Creating a textbox dynamically!!!

Scheduled Pinned Locked Moved C#
designquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mmxguy
    wrote on last edited by
    #1

    Hi, I'am trying 2 create a textbox dynamically in a windowsform application... I want a textbox 2 b created while clicking a button in the form...And it has 2 b loaded thru code rather than thru design ... I tried but was not able 2 create the control...Cud u pleez get me the code 4 this one..??? Thanx n Regards, MMX

    A 1 Reply Last reply
    0
    • M mmxguy

      Hi, I'am trying 2 create a textbox dynamically in a windowsform application... I want a textbox 2 b created while clicking a button in the form...And it has 2 b loaded thru code rather than thru design ... I tried but was not able 2 create the control...Cud u pleez get me the code 4 this one..??? Thanx n Regards, MMX

      A Offline
      A Offline
      Aryadip
      wrote on last edited by
      #2

      hi, this is the way how you do it ... private void button1_Click(object sender, System.EventArgs e) { TextBox tb = new TextBox(); tb.Width = 100; tb.Location = new Point(100,100); this.Controls.Add(tb); } Hope this solves your prob.. regards, Aryadip. Cheers !! and have a Funky day !!

      S 1 Reply Last reply
      0
      • A Aryadip

        hi, this is the way how you do it ... private void button1_Click(object sender, System.EventArgs e) { TextBox tb = new TextBox(); tb.Width = 100; tb.Location = new Point(100,100); this.Controls.Add(tb); } Hope this solves your prob.. regards, Aryadip. Cheers !! and have a Funky day !!

        S Offline
        S Offline
        sreejith ss nair
        wrote on last edited by
        #3

        If you want to see all textbox which added to the form.then you can use the below mentioned code block private void button1_Click(object sender, System.EventArgs e) { Txtbox= new TextBox(); this.Txtbox.Location = new System.Drawing.Point(locx, locy); Txtbox.Width = 100; this.Controls.Add(Txtbox); locx=Txtbox.Location.X; locy=Txtbox.Location.Y+30; } //here i have only one button on my form. On button click i am dynamically creating //textbox control and adding to the control collection of form. //before getting into code you have to declare one private datamember of the type textbox and two integer variables that will help you to keep the location unique. so you can avoid overlapping. private System.Windows.Forms.TextBox Txtbox; private int locx=20,locy=30; hope this will avoid from overlapping:-O Sreejith S S Nair

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups