Enabling menu item

wsyeager

Centurion
Joined
Apr 10, 2003
Messages
140
Location
Weston, FL
Is there any way to enable a menu item that exists on an MDI form from within a child form?

My MDI menu item is declared as follows:
Friend WithEvents mnuAdHocExtOrdStatDlyRptPend As System.Windows.Forms.MainMenu
Me.mnuAdHocExtOrdStatDlyRptPend = New System.Windows.Forms.MainMenu()

Here is the code to initiate my child form:
Private Sub OrdStatDlyRptPend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuAdHocExtOrdStatDlyRptPend.Click

DisableMenus()
Dim frmObject As New frmOrdStatDlyRptPend()
frmObject.MdiParent = Me
StatusBar1.Panels(0).Text = "Loading Customers and ReportIDs..."
frmObject.Show()
StatusBar1.Panels(0).Text = "Processing Ad-hoc Daily Report Pending Order Status functionality..."

End Sub

Now that I'm in the child form, I was under the assumption that since the menu item (mnuAdHocExtOrdStatDlyRptPend) is declared as a "Friend", it should be available to all the methods from within the assembly.... However, when I try and use the following in the child form:
"mnuAdHocExtOrdStatDlyRptPend." and use the dot for the intellisense, nothing pops up.

How can I disable this MDI menu option from within my child form?
 
Try making the mdiParent & the child form public in a module,
then write the code for the child form in the mdiParent menu
item's click event, using the child form's new public name.

ailzaj
 
I just used the following code in my child form to accomplish this task:

Dim frmParentForm As frmMain

frmParentForm = Me.MdiParent

frmParentForm.mnuAdHocExtOrdStatDlyRptPend.Enabled = True
 
One thing to note is that wouldn't quite work if you had Option Strict on (which you should ;)), instead it's good practice to explicitly cast to the frmMain type when you need to:

Visual Basic:
frmParentForm = DirectCast(Me.MdiParent, frmMain)
 
Back
Top