2009-06-16 Ivan N. Zlatev <contact@i-nz.net>
authorIvan Zlatev <ivan@ivanz.com>
Mon, 15 Jun 2009 23:58:31 +0000 (23:58 -0000)
committerIvan Zlatev <ivan@ivanz.com>
Mon, 15 Jun 2009 23:58:31 +0000 (23:58 -0000)
* DataGridView.cs: Avoid calling ReBind twice during the initial data
binding.
[Fixes bug #512807]

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

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

index a2c26d791baffe85d2b348d48f5f6c6103592bde..792724922b22f65acdf61f4251a78544a91739e1 100644 (file)
@@ -1,3 +1,9 @@
+2009-06-16  Ivan N. Zlatev  <contact@i-nz.net>
+
+       * DataGridView.cs: Avoid calling ReBind twice during the initial data 
+       binding.
+       [Fixes bug #512807]
+
 2009-06-16  Ivan N. Zlatev  <contact@i-nz.net>
 
        * DataGridView.cs: Suppress invalidation during data binding.
index f5fbe57b62a857548387d609982f38cfbddf5cde..f8779af57fbd132d4adaf8cf1b0a7f1f7397bee1 100644 (file)
@@ -737,9 +737,15 @@ namespace System.Windows.Forms {
                                        throw new NotSupportedException ("Type cannot be bound.");
                                        
                                ClearBinding ();
-                               dataSource = value;
-                               if (BindingContext != null)
+
+                               // Do not set dataSource prior to te BindingContext check because there is some lazy initialization 
+                               // code which might result in double call to ReBind here and in OnBindingContextChanged
+                               if (BindingContext != null) {
+                                       dataSource = value;
                                        ReBind ();
+                               } else {
+                                       dataSource = value;
+                               }
                                OnDataSourceChanged (EventArgs.Empty);
                        }
                }