2008-02-25 Carlos Alberto Cortez <calberto.cortez@gmail.com>
authorCarlos Alberto Cortez <calberto.cortez@gmail.com>
Tue, 26 Feb 2008 00:40:00 +0000 (00:40 -0000)
committerCarlos Alberto Cortez <calberto.cortez@gmail.com>
Tue, 26 Feb 2008 00:40:00 +0000 (00:40 -0000)
* Binding.cs: Actually implement 2.0 NullValue property. Also
when changing the formatting related properties, only update the state
if formatting_enabled is true (we don't mind otherwise).

svn path=/trunk/mcs/; revision=96605

mcs/class/Managed.Windows.Forms/System.Windows.Forms/Binding.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog

index 7d35be67ec2d5439703e9273582c5709c76ffa47..b2d818ac0f0cf63da69a7ae1d7eea184c25312af 100644 (file)
@@ -53,7 +53,7 @@ namespace System.Windows.Forms {
                private DataSourceUpdateMode datasource_update_mode;
                private ControlUpdateMode control_update_mode;
                private object datasource_null_value;
-               //private object null_value;
+               private object null_value;
                private IFormatProvider format_info;
                private string format_string;
                private bool formatting_enabled;
@@ -92,7 +92,7 @@ namespace System.Windows.Forms {
                        data_member = dataMember;
                        binding_member_info = new BindingMemberInfo (dataMember);
                        datasource_update_mode = dataSourceUpdateMode;
-                       //null_value = nullValue;
+                       null_value = nullValue;
                        format_string = formatString;
                        format_info = formatInfo;
 
@@ -205,7 +205,8 @@ namespace System.Windows.Forms {
                                        return;
 
                                format_info = value;
-                               PushData ();
+                               if (formatting_enabled)
+                                       PushData ();
                        }
                }
 
@@ -221,7 +222,8 @@ namespace System.Windows.Forms {
                                        return;
 
                                format_string = value;
-                               PushData ();
+                               if (formatting_enabled)
+                                       PushData ();
                        }
                }
 #endif
@@ -236,10 +238,15 @@ namespace System.Windows.Forms {
                [DefaultValue (null)]
                public object NullValue {
                        get {
-                               throw new NotImplementedException ();
+                               return null_value;
                        }
                        set {
-                               throw new NotImplementedException ();
+                               if (value == null_value)
+                                       return;
+
+                               null_value = value;
+                               if (formatting_enabled)
+                                       PushData ();
                        }
                }
 #endif
@@ -531,14 +538,20 @@ namespace System.Windows.Forms {
                        if (data_type.IsInstanceOfType (e.Value))
                                return e.Value;
 
-                       if (e.Value == null && data_type == typeof (object))
-                               return Convert.DBNull;
 #if NET_2_0
-                       if (formatting_enabled && e.Value is IFormattable && data_type == typeof (string)) {
-                               IFormattable formattable = (IFormattable) e.Value;
-                               return formattable.ToString (format_string, format_info);
+                       if (formatting_enabled) {
+                               if (e.Value == null || e.Value == Convert.DBNull) {
+                                       return null_value;
+                               }
+                               
+                               if (e.Value is IFormattable && data_type == typeof (string)) {
+                                       IFormattable formattable = (IFormattable) e.Value;
+                                       return formattable.ToString (format_string, format_info);
+                               }
                        }
 #endif
+                       if (e.Value == null && data_type == typeof (object))
+                               return Convert.DBNull;
 
                        return ConvertData (data, data_type);
                }
index f9f56f95aac7dc3ec394e469ef2a2dcd4ae04259..e703d3091ee62c22dff70d9cdea1fabf1bf0b161 100644 (file)
@@ -1,3 +1,9 @@
+2008-02-25  Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+       * Binding.cs: Actually implement 2.0 NullValue property. Also
+       when changing the formatting related properties, only update the state
+       if formatting_enabled is true (we don't mind otherwise).
+
 2008-02-25  Jonathan Pobst  <monkey@jpobst.com>
 
        * ToolStrip.cs: Don't raise ItemClicked for disabled items.