By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,693 Members | 1,415 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,693 IT Pros & Developers. It's quick & easy.

QUESTION ON: For Each Ctl In Me.Controls

P: n/a
Hi friends,

I have the following code in an MDI container (with 3 MDI
forms/children) with a button on the MDI container form.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim Ctl As Control
For Each Ctl In Me.Controls
MsgBox(Ctl.Name)
Next
End Sub

Unfortunately when I click the button (Button1), all that is displayed
in the dialog boxes are "" and the name of the toolbar object.

I thin what I want is something like "For Each Ctl In Me.Children" but
alas, there is no collection ".Children". If my child forms are called
MDI1, MDI2, and MDI3, how can I modify this code to display in the
dialogbox MDI1, MDI2, and MDI3.

Thank you
Tony
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Antony,
I thin what I want is something like "For Each Ctl In Me.Children" but
alas, there is no collection ".Children". Have you tried Me.MdiChildren?

Or Me.OwnedForms?

I suspect MdiChildren is the one you want, while OwnedForms is useful in
similar cases.

Hope this helps
Jay

"Antony" <to****************@hotmail.com> wrote in message
news:37**************************@posting.google.c om... Hi friends,

I have the following code in an MDI container (with 3 MDI
forms/children) with a button on the MDI container form.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim Ctl As Control
For Each Ctl In Me.Controls
MsgBox(Ctl.Name)
Next
End Sub

Unfortunately when I click the button (Button1), all that is displayed
in the dialog boxes are "" and the name of the toolbar object.

I thin what I want is something like "For Each Ctl In Me.Children" but
alas, there is no collection ".Children". If my child forms are called
MDI1, MDI2, and MDI3, how can I modify this code to display in the
dialogbox MDI1, MDI2, and MDI3.

Thank you
Tony

Nov 20 '05 #2

P: n/a
"Antony" <to****************@hotmail.com> schrieb
Hi friends,

I have the following code in an MDI container (with 3 MDI
forms/children) with a button on the MDI container form.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim Ctl As Control
For Each Ctl In Me.Controls
MsgBox(Ctl.Name)
Next
End Sub

Unfortunately when I click the button (Button1), all that is
displayed in the dialog boxes are "" and the name of the toolbar
object.

I thin what I want is something like "For Each Ctl In Me.Children"
but alas, there is no collection ".Children". If my child forms are
called MDI1, MDI2, and MDI3, how can I modify this code to display in
the dialogbox MDI1, MDI2, and MDI3.


Browse the members of "Me". You'll find "MdiChildren".

=>
Dim Form As Form
For Each Form In Me.MdiChildren
MsgBox(Form.Name)
Next
--
Armin

Nov 20 '05 #3

P: n/a
Hello,

"Antony" <to****************@hotmail.com> schrieb:
I have the following code in an MDI container (with 3 MDI
forms/children) with a button on the MDI container form. [...] I thin what I want is something like "For Each Ctl In
Me.Children" but alas, there is no collection ".Children".


\\\
Dim f As Form
Dim c As Control
For Each f In Me.MdiChildren
For Each c In f.Controls
...
Next c
Next f
///

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.