Author: mkestner
Date: 2005-11-01 10:20:04 -0500 (Tue, 01 Nov 2005)
New Revision: 52443

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Menu.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuItem.cs
Log:

2005-10-31  Mike Kestner  <[EMAIL PROTECTED]>

        * Menu.cs: Add items to collection before setting their index.
        * MenuItem.cs : add range checking with ArgumentException like MS.
        [Fixes #76510]


Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2005-11-01 14:57:23 UTC (rev 52442)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2005-11-01 15:20:04 UTC (rev 52443)
@@ -1,3 +1,9 @@
+2005-10-31  Mike Kestner  <[EMAIL PROTECTED]>
+
+       * Menu.cs: Add items to collection before setting their index.
+       * MenuItem.cs : add range checking with ArgumentException like MS.
+       [Fixes #76510]
+
 2005-10-31  Jackson Harper  <[EMAIL PROTECTED]>
 
        * ListBox.cs: Invalidate if the area is visible at all not just

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Menu.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Menu.cs  
2005-11-01 14:57:23 UTC (rev 52442)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Menu.cs  
2005-11-01 15:20:04 UTC (rev 52443)
@@ -309,8 +309,8 @@
                        public virtual int Add (MenuItem mi)
                        {
                                mi.parent_menu = owner;
-                               mi.Index = items.Count;
                                items.Add (mi);
+                               mi.Index = items.Count - 1;
 
                                owner.IsDirty = true;
                                return items.Count - 1;

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuItem.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuItem.cs      
2005-11-01 14:57:23 UTC (rev 52442)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuItem.cs      
2005-11-01 15:20:04 UTC (rev 52443)
@@ -179,7 +179,11 @@
                [Browsable(false)]
                public int Index {
                        get { return index; }
-                       set { index = value; }
+                       set { 
+                               if (Parent != null && Parent.MenuItems != null 
&& (value < 0 || value >= Parent.MenuItems.Count))
+                                       throw new ArgumentException ("'" + 
value + "' is not a valid value for 'value'");
+                               index = value; 
+                       }
                }
 
                [Browsable(false)]

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to