[Mono-bugs] [Bug 71495][Wis] New - Error in MainMenu with one MenuItem

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Wed, 19 Jan 2005 18:59:12 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by rogerio.araujo@gmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=71495

--- shadow/71495	2005-01-19 18:59:11.000000000 -0500
+++ shadow/71495.tmp.6131	2005-01-19 18:59:11.000000000 -0500
@@ -0,0 +1,94 @@
+Bug#: 71495
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: Windows.Forms
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: rogerio.araujo@gmail.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Error in MainMenu with one MenuItem
+
+I can create a MainMenu and add a one MenuItem to it without any error, but
+when i click in this MenuItem in runtime it got the follow error:
+
+Exception 'Index is less than 0 or more than or equal to the list count.
+Parameter name: index
+-1
+	 at System.Collections.ArrayList.get_Item ()
+	 at System.Windows.Forms.MenuAPI.GetMenuFromID ()
+	 at System.Windows.Forms.MenuAPI.TrackPopupMenu ()
+	 at System.Windows.Forms.MenuAPI.MenuBarMove ()
+	 at System.Windows.Forms.MenuAPI.TrackBarMouseEvent ()
+	 at System.Windows.Forms.MainMenu.OnMouseDown ()
+	 at System.Windows.Forms.MainMenu.OnMouseDown ()
+	 at System.Windows.Forms.Form+FormParentWindow.OnMouseDownForm ()
+	 at System.MulticastDelegate.invoke_void_object_MouseEventArgs ()
+	 at System.Windows.Forms.Control.OnMouseDown ()
+	 at System.Windows.Forms.Control.WndProc ()
+	 at System.Windows.Forms.Form+FormParentWindow.WndProc ()
+	 at System.Windows.Forms.Control+ControlNativeWindow.WndProc ()
+	 at System.Windows.Forms.NativeWindow.WndProc ()'
+
+
+Here's the code (you can use code to test the bug 71494 too):
+
+using System;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+namespace MWF
+{
+	public class Test : Form
+	{
+		private MainMenu 	mnuPrincipal;
+		private MenuItem 	mniFechar;
+		private TextBox  txtNome;
+		
+		static void Main(string[] args)
+		{
+	    Application.Run(new Test());
+		}
+		
+		Test()
+		{
+	    BackColor = Color.Blue;
+	    Width     = 200;
+	    Height    = 300;
+	    Text      = "Testando o MWF";
+	    
+	    mnuPrincipal    	= new MainMenu();
+	    mniFechar	     		= new MenuItem();
+	    mniFechar.Text 	 	= "Fechar";
+	    mniFechar.Click  += new EventHandler(this.mniFechar_Click);
+	    mnuPrincipal.MenuItems.Add(mniFechar);
+			
+	    this.Menu = mnuPrincipal;
+
+	    txtNome           = new TextBox();
+	    txtNome.Top       = 100;
+	    txtNome.BackColor = Color.LightBlue;
+	    txtNome.ForeColor = Color.Black;
+	    txtNome.Left      = (Width - txtNome.Width) / 2;
+	    txtNome.Text      = "Teste";
+	    txtNome.Height    = 15;
+	    txtNome.Font      = new Font(FontFamily.GenericMonospace, 12);
+	    Controls.Add(txtNome);
+			
+		}
+		
+		
+		void mniFechar_Click(object src, EventArgs e)
+		{
+	    Application.Exit();
+		}
+	}
+}