hobbes2103 Posted July 23, 2003 Posted July 23, 2003 Hi! I have a form1 with a textbox1. When i press Enter another textbox appears below. As many textboxes as i want can appear. When i click on button1 i want textbox1 to reset and all the other textboxes to disappear. To do this i want to Reload form1 but i can't find the syntax (no Me.Reload found...! :mad: ) What is the syntax to reload a form by pressing on button1? Thank you! Quote
Leaders dynamic_sysop Posted July 23, 2003 Leaders Posted July 23, 2003 can you not just set the other textboxes visible properties to False? Quote
Leaders dynamic_sysop Posted July 23, 2003 Leaders Posted July 23, 2003 you could do something like this : Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim box As Control For Each box In Controls If TypeOf box Is TextBox Then If Not box.Name = "TextBox1" Then box.Text = "" box.Visible = False End If End If Next End Sub Quote
ballisticnylon Posted July 23, 2003 Posted July 23, 2003 If you really want to get rid of the textboxes, you want TextBox.Dispose() Quote "It may be roundly asserted that human ingenuity cannot concoct a cipher which human ingenuity cannot resolve." - Edgar Allan Poe, 1841 I long to accomplish great and noble tasks, but it is my chief duty to accomplish humble tasks as though they were great and noble. The world is moved along, not only by the mighty shoves of its heroes, but also by the aggregate of the tiny pushes of each honest worker. - Helen Keller
Heiko Posted July 23, 2003 Posted July 23, 2003 I don't see how an object can "reload" itself. You can either simulate that from the outside, by disposing and re-creating the whole form, or from inside the form, by manually implementing all necessary steps to a) clear all newly created controls and b) reset the data. Quote .nerd
*Experts* mutant Posted July 23, 2003 *Experts* Posted July 23, 2003 You could have an arraylist to keep track of those newly created textboxes, and then when you want them to disappear go through the array and dispose them: 'Somewhere on top of your code Dim boxes As New ArrayList 'then somewhere else in your keydown event... Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown Dim txtBox As New TextBox 'do some properties here... Me.Controls.Add(txtBox) boxes.Add(txtBox) End Sub 'then somewhere else to dispose them.... Public Sub DestroyBoxes() Dim x As Integer For x = 0 to Boxes.Count - 1 DirectCast(Boxes(x), TextBox).Dispose() Next End Sub 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.