Clear Multiple controls at the same time

G

Guest

Hello everybody,

I heard I could clear (or move spaces) to all controls at ones without
having to call each one of them. If someone remembers how to do that, I will
apreciate your help.

My scenario is a form where I have multiples groupboxes, and in each of
those groups i have text boxes, where users enter data. And I want to have
an option where the user can clear the controls in particular group at once.
And I do not want to be calling for each one of the controls for that
process.
I used to move spaces to each one of them like this:

text1.text = ""
text2.text=""
text3.text = ""
....
textn.text = ""

but there are a lot of controls in this application.


Thanks for any good suggestions.

Edd
 
C

Chris

Eduardo78 said:
Hello everybody,

I heard I could clear (or move spaces) to all controls at ones without
having to call each one of them. If someone remembers how to do that, I will
apreciate your help.

My scenario is a form where I have multiples groupboxes, and in each of
those groups i have text boxes, where users enter data. And I want to have
an option where the user can clear the controls in particular group at once.
And I do not want to be calling for each one of the controls for that
process.
I used to move spaces to each one of them like this:

text1.text = ""
text2.text=""
text3.text = ""
...
textn.text = ""

but there are a lot of controls in this application.


Thanks for any good suggestions.

Edd

For each Ctr as Control in GroupBox.Controls
Ctr.Text = ""
Next

This should work.
Chris
 
G

Guest

Thanks a lot Chris, it worked good, but it also cleared the labels on that
groupbox, how could I make it to clear just the textboxes?
 
C

Chris

Eduardo78 said:
Thanks a lot Chris, it worked good, but it also cleared the labels on that
groupbox, how could I make it to clear just the textboxes?

:

Blah... Ya, sorry about that...

For each Ctr as Control in GroupBox.Controls
if Typeof Ctr is TextBox then
Ctr.Text = ""
End if
Next
 
C

Chris

Curtis said:
Eduardo,

Try this where "me" is your form:

Me.Controls.Clear()

Curtis

Um, that would remove all the controls from his form... That's not what
he is trying to do.

Chris
 
G

Guest

Thanks Curtis, but that command clears evething in the form. I just want to
clear the textboxes in a specific groupbox in the form.

Thanks,

Eduardo
 
G

Guest

Thanks Curtis, but that command clears evething in the form. I just want to
clear the textboxes in a specific groupbox in the form.

Thanks,

Eduardo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top