HighTechTalks DotNet Forums  

How do I access the controls contained in a GroupBox in code?

Dotnet Academic General Discussions microsoft.public.dotnet.academic


Discuss How do I access the controls contained in a GroupBox in code? in the Dotnet Academic General Discussions forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
AdeyS
 
Posts: n/a

Default How do I access the controls contained in a GroupBox in code? - 07-06-2005 , 11:01 AM






If I step through the controls contained in a form using...

For i = 0 to controls.count - 1
msgbox(controls(i).Name)
next i

It will display the names of the controls on the form but will not display
the controls contained within the GroupBox.
What method do I need to use to examine the controls in the GroupBox?
The controls in the group box are a set of 8 comboboxes.


Reply With Quote
  #2  
Old   
Peter van der Goes
 
Posts: n/a

Default Re: How do I access the controls contained in a GroupBox in code? - 07-06-2005 , 12:25 PM







"AdeyS" <AdeyS (AT) discussions (DOT) microsoft.com> wrote

Quote:
If I step through the controls contained in a form using...

For i = 0 to controls.count - 1
msgbox(controls(i).Name)
next i

It will display the names of the controls on the form but will not display
the controls contained within the GroupBox.
What method do I need to use to examine the controls in the GroupBox?
The controls in the group box are a set of 8 comboboxes.

The GroupBox is a container with its own Controls collection, so you'll need
to do something along these lines:

Dim i As Integer

For i = 0 To Controls.Count - 1

MsgBox(Controls(i).Name)

Next i

For i = 0 To GroupBox1.Controls.Count

MsgBox(GroupBox1.Controls(i).Name)

Next i

Note: Not thoroughly tested. You'll want to adapt the code to your
needs/taste.

Peter [MVP Visual Developer]
Jack of all trades, master of none.




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.