Wrox Programmer Forums
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 17th, 2003, 05:20 PM
Authorized User
 
Join Date: Jun 2003
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default MDI window

I have a main form and it has a menu when I click on open form from the menu it open the form1.

Now when I open the form1 I want to disable the open form from the menu.

When I close the form I want to enable the open from from the menu again.

PLease help how can i refer the menu in the mdi form from the form1.
Hope this is clear question. Thanks for all helps
 
Old September 26th, 2003, 02:45 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 428
Thanks: 57
Thanked 2 Times in 2 Posts
Default

I've created nothing but Web based applications in .NET so far, so I've not actually tried this. But in the VB6 days, it was quite simple. From Form1_Load issue this statement:

MainFormName.mnuOpenFormName.enabled = false

From Form1_Unload:

MainFormName.mnuOpenFormName.enabled = true

Of course, you will have to change the form and menu item names to reflect your names, assumign this even works.

If your users don't need to do anything on the Main Form at all while form1 is open, you could do it even more easily by openimg form1 as a modal form.
 
Old October 21st, 2003, 04:16 AM
Registered User
 
Join Date: Oct 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't think that will work Ron! The forms are not seen as shared (static) variables and can't just be referred to in the way you did above.

You could handle the events of the form.

' our Form object
Private WithEvents Form1 As Form

' since we're activating the form, we can make the menu items
' inactive from here
Private Sub OpenFormMenuItem_Click( . . . ) Handles OpenFormMenuItem.Click
   Form1 = New Form1
   Form1.MDIParent = Me
   Form1.Show
   OpenFormMenuItem.Enabled = False
End Sub

' handle the event of the form closing
Private Sub Form1_Closed( . . . ) Handles Form1.Closed
    Form1 = Nothing
    OpenFormMenuItem.Enabled = True
End Sub

----------
NeoTech
 
Old October 23rd, 2003, 01:52 AM
Registered User
 
Join Date: Aug 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

These codes are not working, it cannot disable the menu item :

Private Sub OpenFormMenuItem_Click( . . . ) Handles OpenFormMenuItem.Click
   Form1 = New Form1
   Form1.MDIParent = Me
   Form1.Show
   OpenFormMenuItem.Enabled = False
End Sub



 
Old November 3rd, 2003, 04:46 PM
Authorized User
 
Join Date: Oct 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Rearrange the menu item code like this:
Code:
Private Sub OpenFormMenuItem_Click( . . . ) Handles OpenFormMenuItem.Click
   OpenFormMenuItem.Enabled = False
   Form1 = New Form1
   Form1.MDIParent = Me
   Form1.Show
End Sub
In the Main Form write a small sub as such:
Code:
Public Sub OpenFormItemEnable()
   OpenFormMenuItem.Enabled = True
End Sub
Then in the closing event of Form1 call
Code:
Me.MDIParent.OpenFormItemEnabled()
There are much better ways to do it then creating a one line sub routine but that should work.

What Ron said about the modal forms is a good idea as well.
just replace the .show with .showdialog

Thanks,
Risu





Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying MDI Child Form Menus with MDI Parent ashu_from_india Pro VB 6 3 June 10th, 2008 11:01 PM
Controlling MDI child form from MDI parent panel LuxCoder VB.NET 2002/2003 Basics 7 April 11th, 2007 02:38 PM
Again: Reference between child window of MDI ly_he Pro Visual Basic 2005 1 September 25th, 2006 09:40 PM
Reference between child window of MDI in vb 2005 ly_he Pro Visual Basic 2005 0 September 21st, 2006 03:30 AM
Mdi child window minimizes vsramiya Pro VB 6 2 October 28th, 2005 07:32 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.