Valhalla Legends Archive

Programming => General Programming => .NET Platform => Topic started by: Mangix on September 14, 2005, 05:48 PM

Title: [C#]Menu
Post by: Mangix on September 14, 2005, 05:48 PM
im trying to create a menu with C# by using #develop but it doesnt let me.

the IDE lets me add items to a menu item but it doesnt let me specify the parent menu item. that sounds confusing so here's a screenshot.

http://img44.imageshack.us/img44/637/sdevelop7er.jpg

so does anyone know how i can make the ContextMenu thing have any text? i've tried editing the #develop generated text but i dont see anything for the context menu

edit: bah i solved it. seems i was using the wrong object -_-
Title: Re: [C#]Menu
Post by: MyndFyre on September 14, 2005, 06:14 PM
You needed to use a MainMenu instead of a ContextMenu.
Title: Re: [C#]Menu
Post by: Mangix on September 14, 2005, 06:54 PM
yeah i figured that out

but now i get a diffrent problem. im trying to make an event for one of the menu items but im having difficulty with it. the #develop IDE does it by doing this.Load = System.EventHandler(this.MainFormLoad); but im having difficulty figuring out what to put in the EventHandler cause i dont see any option in the "this" object to handle Menu Events
Title: Re: [C#]Menu
Post by: MyndFyre on September 14, 2005, 07:45 PM
MenuItem events aren't handled via the Load event.  They're handled via the MenuItem.Click event:


this.menuItem1.Click += new EventHandler(menuItem1_Click);
Title: Re: [C#]Menu
Post by: Mangix on September 14, 2005, 08:05 PM
that was a example for a Form's Load Event

i tried this.mnuExit.Click += new System.EventHandler(mnuExit_Click); and got the error
QuoteThe name 'mnuExit_Click' does not exist in the class or namespace 'Mangix.MainForm'(CS0103)'
Title: Re: [C#]Menu
Post by: MyndFyre on September 14, 2005, 09:54 PM
Did you create a function:

public void mnuExit_Click(object sender, EventArgs e) {}

?
Title: Re: [C#]Menu
Post by: Mangix on September 14, 2005, 10:20 PM
just did and it fixed the error. thank you :)