|
-
Oct 13th, 2004, 01:45 PM
#1
Thread Starter
PowerPoster
menus - im losing it!!!
Hi, i think im gonna crack up
im trying to programmatically create menu's and sub menus for the main menu given, it doesnt seem to do it. i FINALLY got all the main menus to appear however all the sub menu's of each menu appear only in one main menu!
why?? what im i doing wrong?
Code:
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.MainMenu fileMenu;
MainMenu someMenu = new MainMenu();
//..
//..
//that is public - the MainMenu object instance
//..
//..
//MAIN method
int numberOfFilesFound = 4; //example
someMenu = this.AddMainMenu("File");
this.Menu = someMenu;
this.AddSubMenus(this.Menu, numberOfFilesFound, " Recent File");
someMenu = this.AddMainMenu("Edit");
this.Menu = someMenu;
this.AddSubMenus(this.Menu, numberOfFilesFound, " Recent File");
someMenu = this.AddMainMenu("View");
this.Menu = someMenu;
this.AddSubMenus(this.Menu, numberOfFilesFound, " Recent File");
}
private MainMenu AddMainMenu(string mainMenuName)
{
//MainMenu mainMenu = new MainMenu();
someMenu.MenuItems.Add(mainMenuName);
this.Menu = someMenu;
return this.Menu;
}
private void AddSubMenus(MainMenu menuName, int numberOfSubItems, string menuItemName)
{
for(int x = 1; x <= numberOfSubItems; x++)
{
menuName.MenuItems[0].MenuItems.Add(x + " " + menuItemName);
}
//this.Menu = menuName;
}
it adds all the submenus to the file menu, the first menu. how can i tell it after its populated the submenus in the main menu, to move on to the next menu and populate to that one, as it should do logically?
-
Oct 13th, 2004, 03:13 PM
#2
Thread Starter
PowerPoster
all i wanna do is return back the next element or get the next MainMenu index! I cant even do that!!!!! AAAAAAAAAAAAAAAAAAAAAAAAAA
-
Oct 13th, 2004, 03:40 PM
#3
Thread Starter
PowerPoster
got it, finally! aaaaaaaaaaa
had to just get the global MainMenu.MenuItem[index number] and it seemed to work
-
Oct 13th, 2004, 04:04 PM
#4
Thread Starter
PowerPoster
question remains...
how would i know how many items there are in a Main Menu and on every sub item to create an onClick event???
the reason im doing this is because i am going to have a "Recently opened files" sub menu system....
see what i mean?
-
Oct 14th, 2004, 02:04 PM
#5
You will have to loop through your menu recursively.
-
Oct 15th, 2004, 04:22 AM
#6
Thread Starter
PowerPoster
im sorry i still dont know what you mean but i think i sorted it by making a new eventhandler when a submenu was being created.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|