2008-09-04 Carlos Alberto Cortez <calberto.cortez@gmail.com>
authorCarlos Alberto Cortez <calberto.cortez@gmail.com>
Thu, 4 Sep 2008 12:59:14 +0000 (12:59 -0000)
committerCarlos Alberto Cortez <calberto.cortez@gmail.com>
Thu, 4 Sep 2008 12:59:14 +0000 (12:59 -0000)
* Binding.cs: When acquiring a BindingManagerBase for the first time,
check that the specified property actually exists in the data source,
and throw an ArgumentException if that's not the case - this is only
done for this scenario, since for later cases (such Position changes)
we throw different exceptions (match .Net).

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

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

index 2c703f7f3ea202a0f2d7f3d25ddfa44624fa3772..5fef8854c447c2574c225c6fadee7733c3e1c22d 100644 (file)
@@ -339,6 +339,11 @@ namespace System.Windows.Forms {
 
                        if (manager == null) {
                                manager = control.BindingContext [data_source, binding_member_info.BindingPath];
+                               if (manager.Position > -1 && 
+                                       TypeDescriptor.GetProperties (manager.Current).Find (binding_member_info.BindingField, true) == null)
+                                       throw new ArgumentException ("Cannot bind to property '" + binding_member_info.BindingField + "' on DataSource.", 
+                                                       "dataMember");
+
                                manager.AddBinding (this);
                                manager.PositionChanged += new EventHandler (PositionChangedHandler);
 
index af467b049cfe07b9c5deaa93891d64f9d92c66fe..9c2946606370db4cccd919a0631e61f18cec8332 100644 (file)
@@ -1,3 +1,11 @@
+2008-09-04  Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+       * Binding.cs: When acquiring a BindingManagerBase for the first time,
+       check that the specified property actually exists in the data source,
+       and throw an ArgumentException if that's not the case - this is only
+       done for this scenario, since for later cases (such Position changes)
+       we throw different exceptions (match .Net).
+
 2008-09-03  Ivan N. Zlatev  <contact@i-nz.net>
 
        * ButtonBase.cs CheckBox.cs, Control.cs, FlowLayoutPanel.cs,