wsyeager Posted May 21, 2003 Posted May 21, 2003 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? Quote Thanks, Bill Yeager (MCP, BCIP) Microsoft Certified Professional Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer YeagerTech Consulting, Inc.
ailzaj Posted May 21, 2003 Posted May 21, 2003 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 Quote
wsyeager Posted May 21, 2003 Author Posted May 21, 2003 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 Quote Thanks, Bill Yeager (MCP, BCIP) Microsoft Certified Professional Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer YeagerTech Consulting, Inc.
*Gurus* divil Posted May 22, 2003 *Gurus* Posted May 22, 2003 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) Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.