how to send commands to a mdiparent from an mdichild

I have been working on my proyect in Visual basic .net but i have some troubles sending an order to disabled the toolbar from a mdichild, i debugged the application i saw that the order was sent but when i look th application i notice that the toolbar is still enabled... what can i do?, what is going on in the proyect with the toolbar. the routine which i'm using is:

Sub Habilitar_Comandos(ByVal estadoAsBoolean)

Dim btAs ToolBarButton, llAs LinkLabel, miAs MenuItem

Dim noAsBoolean =Not estado

ForEach btInMe.ToolBar1.Buttons

bt.Enabled = estado

Next

Me.ToolBar1.Buttons.Item(1).Enabled = no

Me.ToolBar1.Buttons.Item(3).Enabled = no

If estado =TrueOrElse estado =FalseThen

Me.ToolBar1.Buttons.Item(23).Enabled =True

EndIf

End Sub

and the routine in the mdichild for disenabled the toolbar is:

PrivateSub Button1_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles Button1.Click

Dim formaAsNew Form1

forma.Habilitar_Comandos(True)

EndSub

Thanks for everything

[3747 byte] By [MiguelJ] at [2007-12-21]
# 1
Your problem is with "Dim forma As New Form1". You're creating a new form instead of referencing the existing MDI child forms. Try it like this:
Dim child As Form
For Each child In Me.MdiChildren
If TypeOf child Is Form1 Then
CType(child, Form1).Habilitar_Comandos(True)
End If
Next
While you're at it, turn on Option Explicit so that "Enabled = no" doesn't compile.
hpassant at 2007-9-10 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2

What is this doing?

If estado = True OrElse estado = False Then

Me.ToolBar1.Buttons.Item(23).Enabled = True

End If

That says "If estado is true OR false then the button is enabled"... well in that case the button is always enabled.

weirdbeardmt at 2007-9-10 > top of Msdn Tech,Visual Basic,Visual Basic General...