?
Solved

Hide a child form from the parents "Window" menu

Posted on 2009-04-24
8
Medium Priority
?
649 Views
Last Modified: 2013-11-26
Hi


This might be a stupid question but I can't figure it out my self.

I have a VB net 2005 app with an MDI parent which has been added to the project(Including menu structure)
It has a "Window" menu in which I can select Cascade etc. This "Window" menu also contains a list of the child windows that are open.

Now I would like for one of my child windows not to have an entry in the "Window" menu.

How do i do that?

Thanks in advance
0
Comment
Question by:liversen
  • 3
  • 3
  • 2
8 Comments
 
LVL 1

Expert Comment

by:gearboxpc
ID: 24224543
This "Window" menu that you speak of, Is this a contextmenu that you have added to the project?  Or are you refering to the built in context menu that opens when you right click on the form's titlebar?
0
 
LVL 1

Author Comment

by:liversen
ID: 24224670
It is just a mdi form I added to the project using Add New Item and selecting mdiForm
It then comes with its own context menu that has one item called Windows.
It contains by default:
New Window
Cascade
Tile Vertical
Tile Horizontal
Close All
Arrange Icons
____________________
<MDI CHILD 1 NAME>
<MDI CHILD 2 NAME>
<MDI CHILD 3 NAME>

I can not find any code that adds the <MDI CHILD X NAME> to the menu, It's kind of just happening

and I need to make sure that e.g. <MDI CHILD 2 NAME> is not shown in the list.



0
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 400 total points
ID: 24226550
The List is populated automatically when you set the MdiWindowListItem() Property of the Main Menu:
http://msdn.microsoft.com/en-us/library/system.windows.forms.menustrip.mdiwindowlistitem.aspx

In the Image below, you can see the Main Menu (MenuStrip) is selected in the area below the Form.  Then, off to the Right, you can see the MdiWindowListItem() Property is set to WindowsMenu entry.  ("WindowsMenu" is the NAME of the Windows menu in the MenuStrip.  It can be named anything you want and doesn't have to the "Windows" as the Text.)

You can't change the default behavior when using this approach.  If you want a custom menu then you would need to dynamically populate a menu item with the currently open child forms (only the ones that YOU want) each time is is invoked.

Here is the setting:
MdiWindowListItem.jpg
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Accepted Solution

by:
gearboxpc earned 1600 total points
ID: 24228751
I think you are looking for a code example of how to exclude the menu item from showing for a certain child window.  Here is an example using the "DropDownOpening" event of the "WindowsMenu"
 

    Private Sub WindowsMenu_DropDownOpening(ByVal sender As Object, ByVal e As System.EventArgs) Handles WindowsMenu.DropDownOpening
        'Loop through each menu item for the WindowsMenu
        For Each menuItem As ToolStripItem In WindowsMenu.DropDownItems
            'Don't show menu item for child window with caption...
            If menuItem.Text.Contains("Window 2") Then
                menuItem.Visible = False
            End If
        Next
    End Sub

Open in new window

0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 24228874
Nice gearboxpc...we can only make decisions based on the Text of the MenuItem itself though.  We don't have any knowledge of the TYPE of the Form that the MenuItem points to...and for some apps that change the Caption of the form this might not be enough.
0
 
LVL 1

Expert Comment

by:gearboxpc
ID: 24228989
Thanks ~ Idle_Mind...  If you re-read the question from liversen and then check my comment / solution... you will see it does just what liversen asked for.  I am trying to keep it simple and stick to the question.  :)
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 24229070
I didn't say your solution doesn't do what the author asked for.  =(

Have I somehow strayed off question?  =\

I'm merely stating that it would only work if the caption of the form is static or somehow predictable...  =)
(not always the case)
0
 
LVL 1

Author Closing Comment

by:liversen
ID: 31574857
Hi
I'm choosing to go for the solution by gearboxpc because it is simple and it does what I need. In my case the form does not change name/caption so I can use the simple solution.
On the other hand I can see Idle_Mind's point about solving it by populating the menu all manually.
Thanks to both of you
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month15 days, 20 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question