Menu how to

  • Thread starter Thread starter web1110
  • Start date Start date
W

web1110

I have a menu set up as follows.

Main Menu
Windows
Window List
<list of windows)
<Other window options>

When I click on "Window List", I want to pop up a list of window names from
a string array.

I haven't worked with this in a while and am drawing a blank.

Thanx,
Bill
 
Set the MdiList property of your Window List menu item to
true, and as long as you are properly adding the MDI
windows to the form, it will track the changes, know which
one is selected and let you use the window to change
between.
 
I am confused.

Iam not really talking about windows here, but a list of items I get in a
string array.

I have mainMenu1, that has menuItem1 in it. When I click on menuItem1, I
want to display a list menuItems-n under menuItem1. I want to pull these
from a string array. I cannot find how to add additional menu items under
menuItem1. I'm adrift at the moment.

Thanx,
Bill
 
Hi,


Add an Click event handler to your menuItem1 and put this code in:


private void menuItem1_Click(object sender, System.EventArgs e)
{
// get the menuItem user clicked on
MenuItem menuItem = (MenuItem) sender;

// array with window names
string [] sWindowNames = { "window1", "window2"};

foreach (string sWindowName in sWindowNames)
{
// add a new item
menuItem.MenuItems.Add (sWindowName);
}
}

Beside that set the menuItem1's MdiList to true.

Hope this helps.
 
Ahh, my mistake.

Add does exist, it is a method of the MenuItemCollection
type object named MenuItems that both your mainMenu1 and
menuItem1 objects have.

Unfortunately, you cannot directly create a set of
MenuItems from an array of strings, you would have to
iterate through each string, creating a corresponding menu
item and add it to the parent Menu Item using the
MenuItems.Add method of menuItem1.

Sorry about the confusion, I hope this is what you are
looking for.
 
Back
Top