Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

hi

i wish to create textbox after i press a button

if the user press the button 3 times, 3 textbox will be created

these textbox are new..not invisible or disable

can this be done?

kindly guide me at this

thank you in advance

Posted
hi

i wish to create textbox after i press a button

if the user press the button 3 times, 3 textbox will be created

these textbox are new..not invisible or disable

can this be done?

kindly guide me at this

thank you in advance

 

You need to add the new textbox to the container control.

 

i.e.

 

Form1.Controls.Add(TextBox1);

 

Remember to add the events handler to the textbox if you need them.

> NeoDataType.net <

Try my Free .Net Reporting Tool!

  • Leaders
Posted

To add a new textbox...

 

       'Create the textbox
       Dim MyNewTextBox As New TextBox
       'Set the location an size properties how you want them
       MyNewTextBox.Size = New Size(100, 22)
       'Set the text if you want
       'Add the textbox to the form
       Me.Controls.Add(MyNewTextBox)
       'If you want to handle events do it like this
       AddHandler MyNewTextBox.TextChanged, AddressOf DynamicTextBox_TextChanged

 

Easy as pie. Instantiate it, set the properties, add handlers, and add it.

 

Now, if you want to keep a reference to the textbox so you can access it at any time, you could do this by storing it in a variable of type textbox, in an array, or an arraylist, whatever suits your needs.

 

Also, a recommendation: because this code uses a generic handler for any textboxes it creates, if there is any specific information about this textbox that you will need to know about it, I personally would store that info in the form of a string in the textboxes .Tag property.

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...