shingo99 Posted April 1, 2005 Posted April 1, 2005 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 Quote
neodatatype Posted April 1, 2005 Posted April 1, 2005 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. Quote > NeoDataType.net < Try my Free .Net Reporting Tool!
Leaders snarfblam Posted April 1, 2005 Leaders Posted April 1, 2005 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. Quote [sIGPIC]e[/sIGPIC]
shingo99 Posted April 2, 2005 Author Posted April 2, 2005 thank you.. the example is very helpful to me thank you very much Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.