Results 1 to 3 of 3

Thread: Solved. The bug was me :-) .Is this a bug? Deleting added controls

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2003
    Posts
    40

    Solved. The bug was me :-) .Is this a bug? Deleting added controls

    Hello,

    I seem to have stumbled on a bug???

    I use code to add textboxes to a form.
    The part to add them works.
    When the form is loaded I can see all of the created texboxes.


    I have added a button to the form that clears all of the textboxes from the form.

    This is the part where it seems to go wrong.
    Not all of the textboxes are removed from the form.


    Thanks for the help,
    Greets,
    J@B@r

    'Code that creates the buttons when the form is loaded.
    Private Sub AddAndDeleteControl_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Dim intX As Integer = 16
    Dim intY As Integer = 100
    Dim intTextBoxCounter As Integer = 0
    Dim strStartString As String = "txtStringPart"

    For intTextBoxCounter = 1 To 6
    Dim newTextbox As New TextBox
    newTextbox.Size = New Size(100, 20)
    newTextbox.Location = New Point(intX, intY)
    newTextbox.Name = strStartString & intTextBoxCounter
    'intX += 150
    intY += 20
    Me.Controls.Add(newTextbox)
    Next


    End Sub


    'Code that is behind the button
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCleanScreen.Click
    Dim mycontrol As Control


    For Each mycontrol In Me.Controls
    If TypeOf mycontrol Is TextBox Then
    Me.Controls.Remove(mycontrol)
    mycontrol.Dispose()
    'mycontrol.BackColor = System.Drawing.Color.Yellow

    End If
    Next
    End Sub
    Last edited by J@b@r; Oct 12th, 2003 at 03:06 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width