form controls

E

Ed Riley

Hello all - very new to dot net, but not to vb - problem i am having(or
maybe just dont understand how the working of it are yet)

Have a single form with a groupbox - inside this groupbox there are
textboxes. outside this there is a command button. in the click event of the
command button i call a sub from a module. How do i access the controls
inside the groupbox?
I can access a control outside the groupbox (one that is placed directly on
the form) but not inside the groupbox

can someone help ? plssss?? (pullin hair out)

Thanks!
 
P

Phill. W

Ed Riley said:
How do i access the controls inside the groupbox?

Whereas every Contorl /used/ to "belong" to the Form, every Control
is now a Container in its own right.
The Form happens to be a Control, so it can hold other Controls.

To loop through the Controls in the GroupBox, use

For Each eCtl as Control in GroupBox1.Controls
Next

If you want to scan every control "on" the Form, regardless of the
container it happens to be in, you're looking at a Recursive routine,
something like ...

Sub DisableAll( ByVal oaContainer as Control )

For Each eCtl as Control in oaContainer.Controls
eCtl.Enabled = False

DisableAll( eCtl )
Next

End Sub

.... then ...

DisableAll( Me )

HTH,
Phill W.
 

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