Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Thanks,

 

Bill Yeager (MCP, BCIP)

Microsoft Certified Professional

Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer

YeagerTech Consulting, Inc.

Posted

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

Posted

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

Thanks,

 

Bill Yeager (MCP, BCIP)

Microsoft Certified Professional

Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer

YeagerTech Consulting, Inc.

  • *Gurus*
Posted

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:

 

frmParentForm = DirectCast(Me.MdiParent, frmMain)

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...