Author: ivanz
Date: 2008-02-16 10:07:46 -0500 (Sat, 16 Feb 2008)
New Revision: 95890

Modified:
   
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridEntry.cs
   
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGrid.cs
Log:
2008-02-16  Ivan N. Zlatev  <[EMAIL PROTECTED]>

        * PropertyGrid.cs: Clear current items first thing before 
        repopulating subitems.
        * GridEntry.cs: 
         - Handle null StandardValuesCollection.
         - Mark as not editable if there is no PropertyDescriptor and
         if the Converter cannot convert from string.
        [Part of fix for bugs #360666 and #358332]



Modified: 
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- 
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
    2008-02-16 14:58:36 UTC (rev 95889)
+++ 
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
    2008-02-16 15:07:46 UTC (rev 95890)
@@ -1,3 +1,13 @@
+2008-02-16  Ivan N. Zlatev  <[EMAIL PROTECTED]>
+
+       [Backport to 1.9]
+       * PropertyGrid.cs: Clear current items first thing before 
+       repopulating subitems.
+       * GridEntry.cs: 
+        - Handle null StandardValuesCollection.
+        - Mark as not editable if there is no PropertyDescriptor and
+        if the Converter cannot convert from string.
+       [Part of fix for bugs #360666 and #358332]
 2008-02-15  Andreia Gaita <[EMAIL PROTECTED]>
        [Backport to 1.9]
        * XplatUIX11.cs: If the handle is null when posting a message, use the

Modified: 
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridEntry.cs
===================================================================
--- 
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridEntry.cs
 2008-02-16 14:58:36 UTC (rev 95889)
+++ 
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridEntry.cs
 2008-02-16 15:07:46 UTC (rev 95890)
@@ -329,18 +329,15 @@
 
                        UITypeEditor editor = GetEditor ();
                        if (editor != null) {
-                               string error = null;
-                               bool success = false;
                                try {
                                        object value = editor.EditValue 
((ITypeDescriptorContext)this,
                                                                         
container,
                                                                         
this.Value);
-                                       success = SetValue (value, out error);
+                                       string error = null;
+                                       return SetValue (value, out error);
                                } catch (Exception e) {
-                                       error = e.Message;
+                                       property_grid.ShowError (e.Message + 
Environment.NewLine + e.StackTrace);
                                }
-                               if (!success && error != null)
-                                       property_grid.ShowError (error);
                        }
                        return false;
                }
@@ -370,13 +367,15 @@
                                 
PropertyDescriptor.Converter.GetStandardValuesSupported ()) {
                                TypeConverter.StandardValuesCollection values = 
                                        
(TypeConverter.StandardValuesCollection) 
PropertyDescriptor.Converter.GetStandardValues();
-                               for (int i = 0; i < values.Count; i++) {
-                                       if (this.Value.Equals (values[i])){
-                                               if (i < values.Count-1)
-                                                       success = SetValue 
(values[i+1], out error);
-                                               else
-                                                       success = SetValue 
(values[0], out error);
-                                               break;
+                               if (values != null) {
+                                       for (int i = 0; i < values.Count; i++) {
+                                               if (this.Value.Equals 
(values[i])){
+                                                       if (i < values.Count-1)
+                                                               success = 
SetValue (values[i+1], out error);
+                                                       else
+                                                               success = 
SetValue (values[0], out error);
+                                                       break;
+                                               }
                                        }
                                }
                        }
@@ -526,12 +525,13 @@
                public virtual bool IsEditable {
                        get {
                                if (PropertyDescriptor == null)
-                                       return true;
+                                       return false;
                                else if 
(PropertyDescriptor.PropertyType.IsArray)
                                        return false;
                                else if (PropertyDescriptor.IsReadOnly && 
this.ShouldCreateParentInstance)
                                        return true;
-                               else if (PropertyDescriptor.Converter == null)
+                               else if (PropertyDescriptor.Converter == null 
|| 
+                                        
!PropertyDescriptor.Converter.CanConvertFrom (this, typeof (string)))
                                        return false;
                                else if 
(PropertyDescriptor.Converter.GetStandardValuesSupported () &&
                                         
PropertyDescriptor.Converter.GetStandardValuesExclusive ())
@@ -548,10 +548,11 @@
                                // if (PropertyDescriptor != null) {
                                //      Console.WriteLine ("=== [" + 
PropertyDescriptor.Name + "]");
                                //      Console.WriteLine 
("PropertyDescriptor.IsReadOnly: " + PropertyDescriptor.IsReadOnly);
+                               //      Console.WriteLine ("Editor: " + 
(GetEditor () == null ? "none" : GetEditor ().GetType ().Name));
+                               //      Console.WriteLine ("Converter: " + 
(PropertyDescriptor.Converter == null ? "none" : 
PropertyDescriptor.Converter.GetType ().Name));
+                               //      Console.WriteLine 
("Converter.GetStandardValuesSupported: " + 
PropertyDescriptor.Converter.GetStandardValuesSupported ().ToString ());
+                               //      Console.WriteLine 
("Converter.GetStandardValuesExclusive: " + 
PropertyDescriptor.Converter.GetStandardValuesExclusive ().ToString ());
                                //      Console.WriteLine 
("ShouldCreateParentInstance: " + this.ShouldCreateParentInstance);
-                               //      Console.WriteLine ("HasCustomEditor: " 
+ HasCustomEditor);
-                               //      Console.WriteLine ("Converter != null: 
" + (PropertyDescriptor.Converter != null).ToString());
-                               //      Console.WriteLine 
("Converter.GetStandardValuesSupported: " + 
PropertyDescriptor.Converter.GetStandardValuesSupported ().ToString ());
                                //      Console.WriteLine ("CanConvertFrom 
(string): " + PropertyDescriptor.Converter.CanConvertFrom 
((ITypeDescriptorContext)this, typeof (string)));
                                //      Console.WriteLine ("IsArray: " + 
PropertyDescriptor.PropertyType.IsArray.ToString ());
                                // }

Modified: 
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGrid.cs
===================================================================
--- 
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGrid.cs
      2008-02-16 14:58:36 UTC (rev 95889)
+++ 
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGrid.cs
      2008-02-16 15:07:46 UTC (rev 95890)
@@ -1564,6 +1564,7 @@
 
                private void PopulateSubGridItems (GridEntry parentItem)
                {
+                       parentItem.GridItems.Clear ();
                        if (!IsExpandable (parentItem))
                                return;
 
@@ -1576,7 +1577,6 @@
                        if (propertiesCollection == null)
                                return;
 
-                       parentItem.GridItems.Clear ();
                        foreach (PropertyDescriptor property in 
propertiesCollection) {
                                string propertyName = property.Name;
 

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

Reply via email to