G
Greg
I have the following code the dynamically adds a specific number of controls.
for x as integer = 1 to 10
Dim btn as Windows.Forms.Button = New Windows.Forms.Button
btn.Name = "btn" & x
btn.Text = "Test" & x
controls.add(btn)
next x
This results in 10 buttons appearing on the screen. I've excluded the
location info.
Now, in my program the number of buttons varies based on the size of the
form. If the form is decreased in size I will display less buttons. But,
before I update the buttons on the screen, I just remove them all before
refreshing the screen with new buttons.
I use the following code to remove the buttons on the screen.
For Each btn as Windows.Forms.Button in Me.Controls
controls.remove(btn)
Next
In my example, I have 48 buttons displayed on the screen. When the Remove
code above runs it does not delete/remove all of the buttons. If I replace
the controls.Remove command with a debug.print command I can see that every
button is found in the loop. But, when I replace the debug.print and put the
conttols.remove back in all of the buttons are NOT removed. My observation is
that every other button is being removed instead.
Is there any reason why I would be getting this behavior? Is there any
reason why the controls.remove command would not remove a specific button?
I suspect more informaiton is needed on this, but what I'm doing is pretty
straight forward, so I have nothing else to post.
Any help is appreciated.
Greg
for x as integer = 1 to 10
Dim btn as Windows.Forms.Button = New Windows.Forms.Button
btn.Name = "btn" & x
btn.Text = "Test" & x
controls.add(btn)
next x
This results in 10 buttons appearing on the screen. I've excluded the
location info.
Now, in my program the number of buttons varies based on the size of the
form. If the form is decreased in size I will display less buttons. But,
before I update the buttons on the screen, I just remove them all before
refreshing the screen with new buttons.
I use the following code to remove the buttons on the screen.
For Each btn as Windows.Forms.Button in Me.Controls
controls.remove(btn)
Next
In my example, I have 48 buttons displayed on the screen. When the Remove
code above runs it does not delete/remove all of the buttons. If I replace
the controls.Remove command with a debug.print command I can see that every
button is found in the loop. But, when I replace the debug.print and put the
conttols.remove back in all of the buttons are NOT removed. My observation is
that every other button is being removed instead.
Is there any reason why I would be getting this behavior? Is there any
reason why the controls.remove command would not remove a specific button?
I suspect more informaiton is needed on this, but what I'm doing is pretty
straight forward, so I have nothing else to post.
Any help is appreciated.
Greg