2009-01-27 Ivan N. Zlatev <contact@i-nz.net>
authorIvan Zlatev <ivan@ivanz.com>
Tue, 27 Jan 2009 16:46:16 +0000 (16:46 -0000)
committerIvan Zlatev <ivan@ivanz.com>
Tue, 27 Jan 2009 16:46:16 +0000 (16:46 -0000)
* DataGridView.cs: Fix a NRE when setting the CurrentCell to null.

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

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

index ecee88b84e0f876b69bb8328737e7901ea195c7b..384e1003b2240965758b2d7a1cd336bb419ae992 100644 (file)
@@ -1,3 +1,7 @@
+2009-01-27  Ivan N. Zlatev  <contact@i-nz.net>
+
+       * DataGridView.cs: Fix a NRE when setting the CurrentCell to null.
+
 2009-01-27  Ivan N. Zlatev  <contact@i-nz.net>
 
        * XplatUIX11.cs: Fire Timer.Tick even if there is no MainForm for the 
index 422b605b7a9783cb1c5e743723500ba6c3a8c9e7..da66bd65a8d49edd464379f6ef66aa180422f791 100644 (file)
@@ -680,13 +680,12 @@ namespace System.Windows.Forms {
                                /// to the data cache, or the new cell is in a hidden
                                /// row.
                                /////////////////////////////////////////////////////
-                               if (value.DataGridView != this)
+                               if (value == null)
+                                       MoveCurrentCell (-1, -1, true, false, false, true);
+                               else if (value.DataGridView != this)
                                        throw new ArgumentException("The cell is not in this DataGridView.");
-
-                               if (value != null)
-                                       MoveCurrentCell (value.OwningColumn.Index, value.OwningRow.Index, true, false, false, true);
                                else
-                                       MoveCurrentCell (-1, -1, true, false, false, true);
+                                       MoveCurrentCell (value.OwningColumn.Index, value.OwningRow.Index, true, false, false, true);
                        }
                }