Merge pull request #948 from ermshiperete/bug-xamarin-2394
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / DataGridView.cs
index d124e08357123a9bc5b1223222f32971f35e99ca..393d5cba9aebfd3d0da99fd14f52067b5b2f70e6 100644 (file)
@@ -3140,6 +3140,20 @@ namespace System.Windows.Forms {
                                InvalidateRow (i);
                }
 
+               private void UpdateRowHeightInfo (DataGridViewRow row)
+               {
+                       DataGridViewRowHeightInfoNeededEventArgs rowInfo =
+                               new DataGridViewRowHeightInfoNeededEventArgs (row.Index, row.Height, row.MinimumHeight);
+                       OnRowHeightInfoNeeded (rowInfo);
+
+                       if (row.Height != rowInfo.Height || row.MinimumHeight != rowInfo.MinimumHeight) {
+                               row.MinimumHeight = rowInfo.MinimumHeight;
+                               row.Height = rowInfo.Height;
+                               OnRowHeightInfoPushed (new DataGridViewRowHeightInfoPushedEventArgs (row.Index, rowInfo.Height,
+                                                                                                       rowInfo.MinimumHeight));
+                       }
+               }
+
                public void UpdateRowHeightInfo (int rowIndex, bool updateToEnd)
                {
                        if (rowIndex < 0 && updateToEnd)
@@ -3159,33 +3173,12 @@ namespace System.Windows.Forms {
 
                        if (updateToEnd) {
                                for (int i = rowIndex; i < Rows.Count; i++) {
-                                       DataGridViewRow row = Rows[i];
-                                       if (!row.Visible)
-                                               continue;
-
-                                       DataGridViewRowHeightInfoNeededEventArgs rowInfo = 
-                                               new DataGridViewRowHeightInfoNeededEventArgs (row.Index, row.Height, row.MinimumHeight);
-                                       OnRowHeightInfoNeeded (rowInfo);
-
-                                       if (row.Height != rowInfo.Height || row.MinimumHeight != rowInfo.MinimumHeight) {
-                                               row.Height = rowInfo.Height;
-                                               row.MinimumHeight = rowInfo.MinimumHeight;
-                                               OnRowHeightInfoPushed (new DataGridViewRowHeightInfoPushedEventArgs (row.Index, rowInfo.Height, 
-                                                                                                                    rowInfo.MinimumHeight));
-                                       }
+                                       DataGridViewRow row = Rows [i];
+                                       if (row.Visible)
+                                               UpdateRowHeightInfo (row);
                                }
                        } else {
-                               DataGridViewRow row = Rows[rowIndex];
-                               DataGridViewRowHeightInfoNeededEventArgs rowInfo = 
-                                       new DataGridViewRowHeightInfoNeededEventArgs (row.Index, row.Height, row.MinimumHeight);
-                               OnRowHeightInfoNeeded (rowInfo);
-
-                               if (row.Height != rowInfo.Height || row.MinimumHeight != rowInfo.MinimumHeight) {
-                                       row.Height = rowInfo.Height;
-                                       row.MinimumHeight = rowInfo.MinimumHeight;
-                                       OnRowHeightInfoPushed (new DataGridViewRowHeightInfoPushedEventArgs (row.Index, rowInfo.Height, 
-                                                                                                            rowInfo.MinimumHeight));
-                               }
+                               UpdateRowHeightInfo (Rows [rowIndex]);
                        }
                }
 
@@ -3399,6 +3392,7 @@ namespace System.Windows.Forms {
                protected override void Dispose (bool disposing) {
                        if (disposing) {
                                ClearSelection();
+                               currentCell = null;
                                foreach (DataGridViewColumn column in Columns)
                                        column.Dispose();
                                Columns.Clear();
@@ -5467,7 +5461,7 @@ namespace System.Windows.Forms {
                        DataGridViewCell cell = CurrentCell;
                        
                        if (cell != null) {
-                               if (cell.KeyEntersEditMode (new KeyEventArgs ((Keys)m.WParam.ToInt32 ())))
+                               if (cell.KeyEntersEditMode (new KeyEventArgs (((Keys)m.WParam.ToInt32 ()) | XplatUI.State.ModifierKeys)))
                                        BeginEdit (true);
                                if (EditingControl != null && ((Msg)m.Msg == Msg.WM_KEYDOWN || (Msg)m.Msg == Msg.WM_CHAR))
                                        XplatUI.SendMessage (EditingControl.Handle, (Msg)m.Msg, m.WParam, m.LParam);
@@ -5479,7 +5473,7 @@ namespace System.Windows.Forms {
                protected override bool ProcessKeyPreview (ref Message m)
                {
                        if ((Msg)m.Msg == Msg.WM_KEYDOWN && (IsCurrentCellInEditMode || m.HWnd == horizontalScrollBar.Handle || m.HWnd == verticalScrollBar.Handle)) {
-                               KeyEventArgs e = new KeyEventArgs ((Keys)m.WParam.ToInt32 ());
+                               KeyEventArgs e = new KeyEventArgs (((Keys)m.WParam.ToInt32 ()) | XplatUI.State.ModifierKeys);
                        
                                IDataGridViewEditingControl ctrl = (IDataGridViewEditingControl)EditingControlInternal;