How to delete dynamicly loaded textbox's
How to delete dynamicly loaded textbox's
How to delete dynamicly loaded textbox's
How to delete dynamicly loaded textbox's
How to delete dynamicly loaded textbox's
How to delete dynamicly loaded textbox's How to delete dynamicly loaded textbox's How to delete dynamicly loaded textbox's How to delete dynamicly loaded textbox's How to delete dynamicly loaded textbox's How to delete dynamicly loaded textbox's How to delete dynamicly loaded textbox's How to delete dynamicly loaded textbox's
How to delete dynamicly loaded textbox's How to delete dynamicly loaded textbox's
How to delete dynamicly loaded textbox's
Go Back  Xtreme Visual Basic Talk > > > How to delete dynamicly loaded textbox's


Reply
 
Thread Tools Display Modes
  #1  
Old 01-18-2004, 06:32 AM
Vyndrox Vyndrox is offline
Newcomer
 
Join Date: Jan 2004
Posts: 2
Question How to delete dynamicly loaded textbox's


Code:
Dim txtNew As TextBox = New System.Windows.Forms.TextBox() txtNew.Location = New System.Drawing.Point(25 + f, 248) txtNew.MaxLength = 1 txtNew.Name = "txt" & letter txtNew.ReadOnly = True txtNew.Size = New System.Drawing.Size(16, 20) txtNew.Text = letter txtNew.TextAlign = HorizontalAlignment.Center Controls.Add(txtNew)

This is a sample of my code, its from a little game. You have to guess a word, everytime when u input a wrong letter, its dynamicly generates a txtbox with the wrong letter. Now when u guessed the word or it's game over the dynamicly generated textboxes need to be cleared/unloaded. Not just empty but invisible, so you can start another game.
Can somebody help me with it.
Reply With Quote
  #2  
Old 01-20-2004, 07:15 AM
Machaira's Avatar
MachairaHow to delete dynamicly loaded textbox's Machaira is offline
Jedi Coder

* Expert *
 
Join Date: Aug 2002
Location: Abingdon, MD
Posts: 3,438
Default

If you want to remove the controls do something like:
Code:
Dim ilp As Integer For ilp = Me.Controls.Count - 1 To 0 Step -1 If TypeOf Me.Controls(ilp) Is TextBox Then If Me.Controls(ilp).Name <> "TextBox1" Then Me.Controls.RemoveAt(ilp) End If End If Next ilp
This assumes there's a textbox on the form that you don't want to get rid of.
Reply With Quote
  #3  
Old 01-20-2004, 07:54 AM
Vyndrox Vyndrox is offline
Newcomer
 
Join Date: Jan 2004
Posts: 2
Default

Tnx 4 the reply, i also found several other solutions:

Code:
Dim c As Control For Each c In Panel1.Controls If TypeOf c Is TextBox Then c.Dispose() End If Next

or

Code:
Static n Dim s As Integer n = Controls.GetChildIndex(txtNew) For s = 0 To 9 Controls.RemoveAt(n - s) Next s

With the 1st solution u have to place the controls you want to remove in a panel.
And wih the 2nd solution u have to know how many controls there are generated.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete from 2 tables noi_max Database and Reporting 1 12-11-2003 01:18 PM
ADODC - Delete Record: begtrans & CommitTrans punkrawk Database and Reporting 3 01-31-2003 02:56 PM
delete [] or delete? B_old Miscellaneous Languages 7 12-27-2002 08:34 AM
DELETE SQL Statement diver Database and Reporting 7 12-04-2001 07:54 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
How to delete dynamicly loaded textbox's
How to delete dynamicly loaded textbox's
How to delete dynamicly loaded textbox's How to delete dynamicly loaded textbox's
How to delete dynamicly loaded textbox's
How to delete dynamicly loaded textbox's
How to delete dynamicly loaded textbox's How to delete dynamicly loaded textbox's How to delete dynamicly loaded textbox's How to delete dynamicly loaded textbox's How to delete dynamicly loaded textbox's How to delete dynamicly loaded textbox's How to delete dynamicly loaded textbox's
How to delete dynamicly loaded textbox's
How to delete dynamicly loaded textbox's
 
How to delete dynamicly loaded textbox's
How to delete dynamicly loaded textbox's
 
-->