Blob Blame History Raw
--- mono-2.2/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuAPI.cs	2008-11-13 23:30:08.000000000 +0000
+++ mono-2.2/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuAPI-new.cs	2008-11-30 18:37:14.000000000 +0000
@@ -740,7 +740,7 @@
 						SelectItem (item, item.MenuItems [0], false);
 						CurrentMenu = item;
 					}
-				} else if (CurrentMenu.SelectedItem.IsPopup) {
+				} else if (CurrentMenu.SelectedItem != null && CurrentMenu.SelectedItem.IsPopup) {
 					item = CurrentMenu.SelectedItem;
 					ShowSubPopup (CurrentMenu, item);
 					SelectItem (item, item.MenuItems [0], false);
@@ -782,7 +782,8 @@
 					}
 				} else {
 					HideSubPopups (CurrentMenu, TopMenu);
-					CurrentMenu = CurrentMenu.parent_menu;
+					if (CurrentMenu.parent_menu != null)
+					  CurrentMenu = CurrentMenu.parent_menu;
 				}
 				break;
 
--- mono-2.2/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingSource.cs	2008-11-13 23:30:08.000000000 +0000
+++ mono-2.2/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingSource-new.cs	2008-11-30 18:34:35.000000000 +0000
@@ -284,7 +284,9 @@
 		[Browsable (false)]
 		public object Current {
 			get {
-				return currency_manager.Current;
+			  if (currency_manager.Count > 0)
+			    return currency_manager.Current;
+			  return null;
 			}
 		}
 
--- mono-2.2/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRow.cs	2008-11-13 23:30:08.000000000 +0000
+++ mono-2.2/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRow-new.cs	2008-11-30 18:33:10.000000000 +0000
@@ -39,7 +39,6 @@
 		private AccessibleObject accessibilityObject;
 		private DataGridViewCellCollection cells;
 		private ContextMenuStrip contextMenuStrip;
-		private object dataBoundItem;
 		private int dividerHeight;
 		private string errorText;
 		private DataGridViewRowHeaderCell headerCell;
@@ -56,7 +55,6 @@
 			headerCell = new DataGridViewRowHeaderCell();
 			headerCell.SetOwningRow (this);
 			accessibilityObject = new AccessibleObject ();
-			dataBoundItem = null;
 			SetState (DataGridViewElementStates.Visible);
 		}
 
@@ -92,7 +90,15 @@
 		[Browsable (false)]
 		[EditorBrowsable (EditorBrowsableState.Advanced)]
 		public object DataBoundItem {
-			get { return dataBoundItem; }
+			get { 
+			  if (base.DataGridView != null) {
+			    CurrencyManager data = DataGridView.BindingContext[DataGridView.DataSource] as CurrencyManager;
+			    if (data != null) {
+			      return data.List[base.Index];
+			    }
+			  }
+			  return null;
+			}
 		}
 
 		[Browsable (true)]
--- mono-2.2/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GroupBoxRenderer.cs	2008-09-10 17:22:36.000000000 +0100
+++ mono-2.2/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GroupBoxRenderer-new.cs	2008-11-30 18:29:53.000000000 +0000
@@ -99,7 +99,7 @@
 				// part of the bounds as height, they use it as the bottom, so the boxes are drawn in completely different
 				// places.  Rather than emulate this bug, we do it correctly.  After googling for a while, I don't think
 				// anyone has ever actually used this class for anything, so it should be fine.  :)
-				Rectangle new_bounds = new Rectangle (bounds.Left, bounds.Top + (int)(font_size.Height / 2) - 1, bounds.Width, bounds.Height - (int)(font_size.Height / 2) + 1);
+				Rectangle new_bounds = new Rectangle (bounds.Left, bounds.Top + (int)(font_size.Height / 2), bounds.Width, bounds.Height - (int)(font_size.Height / 2));
 				
 				// Don't paint over the background where we are going to put the text
 				Region old_clip = g.Clip;
@@ -110,7 +110,11 @@
 				g.Clip = old_clip;
 
 				if (groupBoxText != String.Empty)
+				{
+				  if (textColor == Color.Empty) 
+				    textColor = SystemColors.ControlText;
 					TextRenderer.DrawText (g, groupBoxText, font, new Point (bounds.Left + 8, bounds.Top), textColor, flags);
+				}
 			}
 		}
 
--- mono-2.2/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridView.cs	2008-11-13 23:30:08.000000000 +0000
+++ mono-2.2/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridView-new.cs	2008-11-30 19:31:54.000000000 +0000
@@ -671,8 +671,7 @@
 				if (value.DataGridView != this) {
 					throw new ArgumentException("The cell is not in this DataGridView.");
 				}
-				currentCell = value;
-				currentRow = currentCell.OwningRow;
+				SetCurrentCellAddressCore(value.ColumnIndex, value.RowIndex, false, true, false);
 			}
 		}
 
@@ -683,7 +682,11 @@
 
 		[Browsable (false)]
 		public DataGridViewRow CurrentRow {
-			get { return currentRow; }
+			get { 
+			  if (currentCell != null)
+			    return currentCell.OwningRow;
+			  return null;
+			}
 		}
 
 		[DefaultValue ("")]
@@ -4203,26 +4206,18 @@
 				Invalidate ();
 				return;
 			}
-			
-			if (cell == currentCell) {
-				BeginEdit (true);
-				return;
-			} else if (currentCell != null) {
-				EndEdit ();
-				OnCellLeave(new DataGridViewCellEventArgs(currentCell.ColumnIndex, currentCell.RowIndex));
-			}
-			currentCell = cell;
-			currentCellAddress = new Point (currentCell.ColumnIndex, currentCell.RowIndex);
-			currentRow = cell.OwningRow;
-			OnCurrentCellChanged(EventArgs.Empty);
-			OnCellEnter(new DataGridViewCellEventArgs(cell.ColumnIndex, cell.RowIndex));
-			if (editMode == DataGridViewEditMode.EditOnEnter) {
-				BeginEdit (true);
-			}
+			SetCurrentCellAddressCore(cell.ColumnIndex, cell.RowIndex, false, true, true);
 			Invalidate();
 			return;
 		}
 
+	  private void UpdateBindingPosition(int position)
+	  {
+	    BindingSource source = dataSource as BindingSource;
+	    if (source != null && source.CurrencyManager != null)
+	      source.CurrencyManager.Position = position;
+	  }
+
 		protected override void OnMouseEnter (EventArgs e)
 		{
 			base.OnMouseEnter(e);
@@ -5307,7 +5302,7 @@
 			base.SetBoundsCore(x, y, width, height, specified);
 		}
 
-		[MonoTODO ("Does not use validateCurrentCell or throughMouseClick")]
+		[MonoTODO ("Does not use validateCurrentCell")]
 		protected virtual bool SetCurrentCellAddressCore (int columnIndex, int rowIndex, bool setAnchorCellAddress, bool validateCurrentCell, bool throughMouseClick)
 		{
 			if ((columnIndex < 0 || columnIndex > Columns.Count - 1) && rowIndex != -1)
@@ -5327,12 +5322,25 @@
 				
 			if (setAnchorCellAddress)
 				anchor_cell = new Point (columnIndex, rowIndex);
-
+			DataGridViewCell oldCell = CurrentCell;
+			currentCell = cell;
 			currentCellAddress = new Point (columnIndex, rowIndex);
-			CurrentCell = cell;
-			
-			OnCurrentCellChanged (EventArgs.Empty);
-			
+			if (currentCell != oldCell) {
+			  if (oldCell != null) {
+			    EndEdit();
+			    OnCellLeave(new DataGridViewCellEventArgs(oldCell.ColumnIndex, oldCell.RowIndex));
+			    OnRowLeave(new DataGridViewCellEventArgs(oldCell.ColumnIndex, oldCell.RowIndex));
+			  }
+			  UpdateBindingPosition(currentCell.RowIndex);
+			  OnRowEnter(new DataGridViewCellEventArgs(cell.ColumnIndex, cell.RowIndex));
+			  OnCellEnter(new DataGridViewCellEventArgs(cell.ColumnIndex, cell.RowIndex));
+			  OnCurrentCellChanged(EventArgs.Empty);
+			  if (throughMouseClick && editMode == DataGridViewEditMode.EditOnEnter)
+			    BeginEdit(true);
+			} else {
+			  if (throughMouseClick)
+			    BeginEdit(true);
+			}
 			return true;
 		}