2008-04-09 Jonathan Pobst <monkey@jpobst.com>
authorJonathan Pobst <monkey@jpobst.com>
Wed, 9 Apr 2008 16:09:42 +0000 (16:09 -0000)
committerJonathan Pobst <monkey@jpobst.com>
Wed, 9 Apr 2008 16:09:42 +0000 (16:09 -0000)
* DataGridViewCell.cs: Fix up some formatting and painting code.
* DataGridViewImageCell.cs: Implement some NIEX methods.

2008-04-09  Jonathan Pobst  <monkey@jpobst.com>

* DataGridViewImageCellTest.cs: Add.

2008-04-09  Jonathan Pobst  <monkey@jpobst.com>

* System.Windows.Forms_test.dll.sources: Add DataGridViewImageCellTest.cs.

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

mcs/class/Managed.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCell.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewImageCell.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewImageCellTest.cs [new file with mode: 0644]

index a8c171dbb5348bcafb77d3124f761bf12a2cf9e4..6f9ad0e4727fb9f5aa9571a9a602646cc77a899b 100644 (file)
@@ -1,3 +1,7 @@
+2008-04-09  Jonathan Pobst  <monkey@jpobst.com>
+
+       * System.Windows.Forms_test.dll.sources: Add DataGridViewImageCellTest.cs.
+
 2008-04-08  Everaldo Canuto  <ecanuto@novell.com>
 
        * Makefile: GENERATE_RESOURCES var added to help on resources generation. 
index 5b6af5b6c4b746ba5b2d8e8384afbaa3708542b6..71255302385188ea214d175fd69bc143811e8ccc 100644 (file)
@@ -1,3 +1,8 @@
+2008-04-09  Jonathan Pobst  <monkey@jpobst.com>
+
+       * DataGridViewCell.cs: Fix up some formatting and painting code.
+       * DataGridViewImageCell.cs: Implement some NIEX methods.
+
 2008-04-09  Jonathan Pobst  <monkey@jpobst.com>
 
        * ToolStripItemCollection.cs: What moving an item from one owner
index 8b922b0663089ff9546ec25adedb8b1ae4f06c09..ac0562929a5fbd3ca9d1a3aab9f1d7c744320fbf 100644 (file)
@@ -160,7 +160,9 @@ namespace System.Windows.Forms {
                                if (style.Format != String.Empty && FormattedValueType == typeof(string)) {
                                        return String.Format("{0:" + style.Format + "}", Value);
                                }
-                               return Convert.ChangeType(Value, FormattedValueType, style.FormatProvider);
+                               
+                               return GetFormattedValue (Value, RowIndex, ref style, null, null, DataGridViewDataErrorContexts.Formatting);
+                               //return Convert.ChangeType(Value, FormattedValueType, style.FormatProvider);
                        }
                }
 
@@ -335,9 +337,6 @@ namespace System.Windows.Forms {
                                if (DataGridView == null)
                                        return new Size (-1, -1);
                                        
-                               if (RowIndex == -1)
-                                       throw new InvalidOperationException ("Getting the Size property of a cell in a shared row is not a valid operation.");
-                                       
                                return GetSize (RowIndex);
                        }
                }
@@ -1040,6 +1039,9 @@ namespace System.Windows.Forms {
 
                protected virtual Size GetSize (int rowIndex)
                {
+                       if (RowIndex == -1)
+                               throw new InvalidOperationException ("Getting the Size property of a cell in a shared row is not a valid operation.");
+
                        return new Size (OwningColumn.Width, OwningRow.Height);
                }
 
@@ -1414,13 +1416,20 @@ namespace System.Windows.Forms {
                internal void PaintWork (Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
                {
                        object value;
+                       object formattedvalue;
                        
-                       if (RowIndex == -1 && !(this is DataGridViewColumnHeaderCell))
+                       if (RowIndex == -1 && !(this is DataGridViewColumnHeaderCell)) {
                                value = null;
-                       else
+                               formattedvalue = null;
+                       } else if (RowIndex == -1) {
                                value = Value;
+                               formattedvalue = Value;
+                       } else {
+                               value = Value;
+                               formattedvalue = FormattedValue;
+                       }
 
-                       DataGridViewCellPaintingEventArgs pea = new DataGridViewCellPaintingEventArgs (DataGridView, graphics, clipBounds, cellBounds, rowIndex, columnIndex, cellState, value, value, ErrorText, cellStyle, advancedBorderStyle, paintParts);
+                       DataGridViewCellPaintingEventArgs pea = new DataGridViewCellPaintingEventArgs (DataGridView, graphics, clipBounds, cellBounds, rowIndex, columnIndex, cellState, value, formattedvalue, ErrorText, cellStyle, advancedBorderStyle, paintParts);
                        DataGridView.OnCellPaintingInternal (pea);
                        
                        if (pea.Handled)
@@ -1433,6 +1442,10 @@ namespace System.Windows.Forms {
                        if (valuex != value) {
                                valuex = value;
                                RaiseCellValueChanged (new DataGridViewCellEventArgs (ColumnIndex, RowIndex));
+                               
+                               if (DataGridView != null)
+                                       DataGridView.InvalidateCell (this);
+                                       
                                return true;
                        }
                        return false;
index eac6c67b15a44a5d733aedcf7ba623d2eb077917..bfd07c63342afa474ca44d09a2a5f93b10a95a5d 100644 (file)
@@ -38,6 +38,8 @@ namespace System.Windows.Forms {
                private DataGridViewImageCellLayout imageLayout;
                private bool valueIsIcon;
 
+               private static Image missing_image;
+               
                public DataGridViewImageCell (bool valueIsIcon) {
                        this.valueIsIcon = valueIsIcon;
                        this.imageLayout = DataGridViewImageCellLayout.NotSet;
@@ -46,8 +48,13 @@ namespace System.Windows.Forms {
                public DataGridViewImageCell () : this(false) {
                }
 
+               static DataGridViewImageCell ()
+               {
+                       missing_image = ResourceImageLoader.Get ("image-missing.png");
+               }
+               
                public override object DefaultNewRowValue {
-                       get { return defaultNewRowValue; }
+                       get { return missing_image; }
                }
 
                [DefaultValue ("")]
@@ -86,7 +93,7 @@ namespace System.Windows.Forms {
                                if (base.ValueType != null) {
                                        return base.ValueType;
                                }
-                               if (OwningColumn != null) {
+                               if (OwningColumn != null && OwningColumn.ValueType != null) {
                                        return OwningColumn.ValueType;
                                }
                                if (valueIsIcon) {
@@ -115,30 +122,113 @@ namespace System.Windows.Forms {
                        return new DataGridViewImageCellAccessibleObject(this);
                }
 
-               protected override Rectangle GetContentBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
-                       throw new NotImplementedException();
+               protected override Rectangle GetContentBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex)
+               {
+                       if (DataGridView == null)
+                               return Rectangle.Empty;
+                               
+                       Rectangle image_bounds = Rectangle.Empty;
+                       Image i = (Image)GetFormattedValue (Value, rowIndex, ref cellStyle, null, null, DataGridViewDataErrorContexts.PreferredSize);
+                       
+                       if (i == null)
+                               i = missing_image;
+
+                       switch (imageLayout) {
+                               case DataGridViewImageCellLayout.NotSet:
+                               case DataGridViewImageCellLayout.Normal:
+                                       image_bounds = new Rectangle ((Size.Width - i.Width) / 2, (Size.Height - i.Height) / 2, i.Width, i.Height);
+                                       break;
+                               case DataGridViewImageCellLayout.Stretch:
+                                       image_bounds = new Rectangle (Point.Empty, Size);
+                                       break;
+                               case DataGridViewImageCellLayout.Zoom:
+                                       Size image_size;
+
+                                       if (((float)i.Width / (float)i.Height) >= ((float)Size.Width / (float)Size.Height))
+                                               image_size = new Size (Size.Width, (i.Height * Size.Width) / i.Width);
+                                       else
+                                               image_size = new Size ((i.Width * Size.Height) / i.Height, Size.Height);
+
+                                       image_bounds = new Rectangle ((Size.Width - image_size.Width) / 2, (Size.Height - image_size.Height) / 2, image_size.Width, image_size.Height);
+                                       break;
+                       }
+                       
+                       return image_bounds;
                }
 
-               protected override Rectangle GetErrorIconBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
-                       throw new NotImplementedException();
+               [MonoTODO ()]
+               protected override Rectangle GetErrorIconBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex)
+               {
+                       return Rectangle.Empty;
                }
 
-               protected override object GetFormattedValue (object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context) {
-                       throw new NotImplementedException();
+               protected override object GetFormattedValue (object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
+               {
+                       return base.GetFormattedValue (value, rowIndex, ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context);
                }
 
-               protected override Size GetPreferredSize (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize) {
-                       throw new NotImplementedException();
+               protected override Size GetPreferredSize (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize)
+               {
+                       if (Value == null)
+                               return new Size (21, 20);
+                               
+                       Image i = (Image)GetFormattedValue (Value, rowIndex, ref cellStyle, null, null, DataGridViewDataErrorContexts.PreferredSize);
+                       
+                       if (i != null)
+                               return new Size (i.Width + 1, i.Height + 1);
+
+                       return new Size (21, 20);
                }
 
-               protected override object GetValue (int rowIndex) {
-                       throw new NotImplementedException();
+               protected override object GetValue (int rowIndex)
+               {
+                       return base.GetValue (rowIndex);
                }
 
-               protected override void Paint (Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) {
-                       throw new NotImplementedException();
+               protected override void Paint (Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
+               {
+                       base.Paint (graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
                }
+               
+               internal override void PaintPartContent (Graphics graphics, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, DataGridViewCellStyle cellStyle, object formattedValue)
+               {
+                       Image i;
+                       
+                       if (formattedValue == null)
+                               i = missing_image;
+                       else
+                               i = (Image)formattedValue;
+
+                       Rectangle image_bounds = Rectangle.Empty;
+
+                       switch (imageLayout) {
+                               case DataGridViewImageCellLayout.NotSet:
+                               case DataGridViewImageCellLayout.Normal:
+                                       image_bounds = new Rectangle ((Size.Width - i.Width) / 2, (Size.Height - i.Height) / 2, i.Width, i.Height);
+                                       break;
+                               case DataGridViewImageCellLayout.Stretch:
+                                       image_bounds = new Rectangle (Point.Empty, cellBounds.Size);
+                                       break;
+                               case DataGridViewImageCellLayout.Zoom:
+                                       Size image_size;
+
+                                       if (((float)i.Width / (float)i.Height) >= ((float)Size.Width / (float)Size.Height))
+                                               image_size = new Size (Size.Width, (i.Height * Size.Width) / i.Width);
+                                       else
+                                               image_size = new Size ((i.Width * Size.Height) / i.Height, Size.Height);
+
+                                       image_bounds = new Rectangle ((Size.Width - image_size.Width) / 2, (Size.Height - image_size.Height) / 2, image_size.Width, image_size.Height);
+                                       break;
+                               default:
+                                       break;
+                       }
 
+                       image_bounds.X += cellBounds.Left;
+                       image_bounds.Y += cellBounds.Top;
+                       
+                       graphics.DrawImage (i, image_bounds);
+               }
+               
                protected class DataGridViewImageCellAccessibleObject : DataGridViewCellAccessibleObject {
 
                        public DataGridViewImageCellAccessibleObject (DataGridViewCell owner) : base(owner) {
index ccb96c866ae4552ac9fc930336a2af748ee9cfea..0e5dfe35903d4d8f947530ed265d5e8be53d7f5e 100644 (file)
@@ -58,6 +58,7 @@ System.Windows.Forms/DataGridViewComboBoxCellTest.cs
 System.Windows.Forms/DataGridViewCommon.cs
 System.Windows.Forms/DataGridViewElementTest.cs
 System.Windows.Forms/DataGridViewLinkCellTest.cs
+System.Windows.Forms/DataGridViewImageCellTest.cs
 System.Windows.Forms/DataGridViewRowCollectionTest.cs
 System.Windows.Forms/DataGridViewRowHeaderTest.cs
 System.Windows.Forms/DataGridViewRowTest.cs
index f73648cd6b7b8bde8b4a73f892e7b2980c05de65..d520065fdbab1e7ff0794438df07878b23b44ca9 100644 (file)
@@ -1,3 +1,7 @@
+2008-04-09  Jonathan Pobst  <monkey@jpobst.com>
+
+       * DataGridViewImageCellTest.cs: Add.
+
 2008-04-08  Jonathan Pobst  <monkey@jpobst.com>
 
        * DataGridViewCheckBoxCellTest.cs: Add.
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewImageCellTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewImageCellTest.cs
new file mode 100644 (file)
index 0000000..33dd87e
--- /dev/null
@@ -0,0 +1,877 @@
+//
+// DataGridViewImageCellTest.cs - Unit tests for
+// System.Windows.Forms.DataGridViewImageCellTest
+//
+// Author:
+//     Gert Driesen  <drieseng@users.sourceforge.net>
+//
+// Copyright (C) 2007 Gert Driesen
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+using System.Windows.Forms;
+
+using NUnit.Framework;
+using System.Drawing;
+using System.Threading;
+using System.ComponentModel;
+
+namespace MonoTests.System.Windows.Forms
+{
+       [TestFixture]
+       public class DataGridViewImageCellTest
+       {
+               [Test]
+               public void Value ()
+               {
+                       DataGridViewImageCell tbc = new DataGridViewImageCell ();
+                       Assert.IsNull (tbc.Value, "#1");
+                       tbc.Value = string.Empty;
+                       Assert.AreEqual (string.Empty, tbc.Value, "#2");
+                       tbc.Value = 5;
+                       Assert.AreEqual (5, tbc.Value, "#3");
+                       tbc.Value = null;
+                       Assert.IsNull (tbc.Value, "#4");
+               }
+
+               [Test]
+               public void ColumnIndex ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (-1, c.ColumnIndex, "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreEqual (0, dgv.Rows[0].Cells[0].ColumnIndex, "A2");
+               }
+
+               /* font measurement dependent
+               [Test]
+               public void ContentBounds ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (Rectangle.Empty, c.ContentBounds, "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreEqual (new Rectangle (0, 2, 14, 16), dgv.Rows[0].Cells[0].ContentBounds, "A2");
+               }
+               */
+
+               [Test]
+               public void ContextMenuStrip ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (null, c.ContextMenuStrip, "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       ContextMenuStrip cms1 = new ContextMenuStrip ();
+                       cms1.Items.Add ("hey");
+
+                       ContextMenuStrip cms2 = new ContextMenuStrip ();
+                       cms2.Items.Add ("yo");
+
+                       dgv.Rows[0].ContextMenuStrip = cms1;
+                       Assert.AreEqual (null, dgv.Rows[0].Cells[0].ContextMenuStrip, "A2");
+
+                       dgv.Rows[0].Cells[0].ContextMenuStrip = cms2;
+                       Assert.AreSame (cms2, dgv.Rows[0].Cells[0].ContextMenuStrip, "A3");
+               }
+
+               [Test]
+               public void DataGridView ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (null, c.DataGridView, "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreSame (dgv, dgv.Rows[0].Cells[0].DataGridView, "A2");
+               }
+
+               [Test]
+               public void DefaultNewRowValue ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual ("System.Drawing.Bitmap", c.DefaultNewRowValue.GetType ().ToString (), "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreEqual ("System.Drawing.Bitmap", dgv.Rows[0].Cells[0].DefaultNewRowValue.GetType ().ToString (), "A2");
+               }
+
+               [Test]
+               public void Displayed ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (false, c.Displayed, "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreEqual (false, dgv.Rows[0].Cells[0].Displayed, "A2");
+               }
+
+               [Test]
+               public void EditedFormattedValue ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (null, c.EditedFormattedValue, "A1");
+               }
+
+               [Test]
+               public void FormattedValueType ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (typeof (Image), c.FormattedValueType, "A1");
+               }
+
+               [Test]
+               public void Frozen ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (false, c.Frozen, "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreEqual (false, dgv.Rows[0].Cells[0].Frozen, "A2");
+
+                       dgv.Columns[0].Frozen = true;
+                       dgv.Rows[0].Frozen = true;
+                       Assert.AreEqual (true, dgv.Rows[0].Cells[0].Frozen, "A3");
+               }
+
+               [Test]
+               public void HasStyle ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (false, c.HasStyle, "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreEqual (false, dgv.Rows[0].Cells[0].HasStyle, "A2");
+
+                       dgv.Rows[0].Cells[0].Style.BackColor = Color.Orange;
+                       Assert.AreEqual (true, dgv.Rows[0].Cells[0].HasStyle, "A3");
+               }
+
+               [Test]
+               public void InheritedState ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (DataGridViewElementStates.ResizableSet, c.InheritedState, "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreEqual (DataGridViewElementStates.ResizableSet | DataGridViewElementStates.Resizable | DataGridViewElementStates.Visible, dgv.Rows[0].Cells[0].InheritedState, "A2");
+
+                       dgv.Rows[0].Selected = true;
+                       Assert.AreEqual (DataGridViewElementStates.Selected | DataGridViewElementStates.ResizableSet | DataGridViewElementStates.Resizable | DataGridViewElementStates.Visible, dgv.Rows[0].Cells[0].InheritedState, "A3");
+
+                       dgv.Rows[0].Selected = false;
+                       dgv.Columns[0].Selected = true;
+                       Assert.AreEqual (DataGridViewElementStates.ResizableSet | DataGridViewElementStates.Resizable | DataGridViewElementStates.Visible, dgv.Rows[0].Cells[0].InheritedState, "A4");
+               }
+
+               [Test]
+               public void InheritedStyle ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreEqual (SystemColors.Window, dgv.Rows[0].Cells[0].InheritedStyle.BackColor, "A1");
+
+                       dgv.DefaultCellStyle.BackColor = Color.Firebrick;
+                       Assert.AreEqual (Color.Firebrick, dgv.Rows[0].Cells[0].InheritedStyle.BackColor, "A2");
+
+                       dgv.Columns[0].DefaultCellStyle.BackColor = Color.FloralWhite;
+                       Assert.AreEqual (Color.FloralWhite, dgv.Rows[0].Cells[0].InheritedStyle.BackColor, "A3");
+
+                       dgv.RowsDefaultCellStyle.BackColor = Color.DeepPink;
+                       Assert.AreEqual (Color.DeepPink, dgv.Rows[0].Cells[0].InheritedStyle.BackColor, "A4");
+
+                       dgv.Rows[0].DefaultCellStyle.BackColor = Color.DeepSkyBlue;
+                       Assert.AreEqual (Color.DeepSkyBlue, dgv.Rows[0].Cells[0].InheritedStyle.BackColor, "A5");
+
+                       dgv.Rows[0].Cells[0].Style.BackColor = Color.DodgerBlue;
+                       Assert.AreEqual (Color.DodgerBlue, dgv.Rows[0].Cells[0].InheritedStyle.BackColor, "A6");
+               }
+
+               [Test]
+               public void IsInEditMode ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (false, c.IsInEditMode, "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreEqual (false, dgv.Rows[0].Cells[0].IsInEditMode, "A2");
+               }
+
+               [Test]
+               public void OwningColumn ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (null, c.OwningColumn, "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreSame (dgv.Columns[0], dgv.Rows[0].Cells[0].OwningColumn, "A2");
+               }
+
+               [Test]
+               public void OwningRow ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (null, c.OwningRow, "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreSame (dgv.Rows[0], dgv.Rows[0].Cells[0].OwningRow, "A2");
+               }
+
+               /* Font measurement dependent *
+               [Test]
+               public void PreferredSize ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (new Size (-1, -1), c.PreferredSize, "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreEqual (new Size (21, 20), dgv.Rows[0].Cells[0].PreferredSize, "A2");
+
+                       dgv.Rows[0].Cells[0].Value = new Bitmap (20, 20);
+                       Assert.AreEqual (new Size (21, 21), dgv.Rows[0].Cells[0].PreferredSize, "A3");
+
+                       dgv.Rows[0].Cells[0].Value = new Bitmap (32, 32);
+                       Assert.AreEqual (new Size (33, 33), dgv.Rows[0].Cells[0].PreferredSize, "A4");
+               }
+                */
+
+               [Test]
+               public void ReadOnly ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (false, c.ReadOnly, "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreEqual (false, dgv.Rows[0].Cells[0].ReadOnly, "A2");
+
+                       dgv.Rows[0].ReadOnly = true;
+                       Assert.AreEqual (true, dgv.Rows[0].Cells[0].ReadOnly, "A3");
+
+                       dgv.Rows[0].Cells[0].ReadOnly = false;
+                       Assert.AreEqual (false, dgv.Rows[0].Cells[0].ReadOnly, "A4");
+               }
+
+               [Test]
+               public void Resizable ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (false, c.Resizable, "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreEqual (true, dgv.Rows[0].Cells[0].Resizable, "A2");
+
+                       dgv.Rows[0].Resizable = DataGridViewTriState.False;
+                       Assert.AreEqual (true, dgv.Rows[0].Cells[0].Resizable, "A3");
+
+                       dgv.Columns[0].Resizable = DataGridViewTriState.False;
+                       Assert.AreEqual (false, dgv.Rows[0].Cells[0].Resizable, "A4");
+
+                       dgv.Columns[0].Resizable = DataGridViewTriState.True;
+                       dgv.Rows[0].Resizable = DataGridViewTriState.True;
+                       Assert.AreEqual (true, dgv.Rows[0].Cells[0].Resizable, "A5");
+
+                       dgv.AllowUserToResizeColumns = false;
+                       Assert.AreEqual (true, dgv.Rows[0].Cells[0].Resizable, "A6");
+
+                       dgv.AllowUserToResizeRows = false;
+                       Assert.AreEqual (true, dgv.Rows[0].Cells[0].Resizable, "A7");
+
+                       dgv.Columns[0].Resizable = DataGridViewTriState.NotSet;
+                       Assert.AreEqual (true, dgv.Rows[0].Cells[0].Resizable, "A8");
+
+                       dgv.Rows[0].Resizable = DataGridViewTriState.NotSet;
+                       Assert.AreEqual (false, dgv.Rows[0].Cells[0].Resizable, "A9");
+               }
+
+               [Test]
+               public void RowIndex ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (-1, c.RowIndex, "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreEqual (0, dgv.Rows[0].Cells[0].RowIndex, "A2");
+               }
+
+               [Test]
+               public void Selected ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (false, c.Selected, "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreEqual (false, dgv.Rows[0].Cells[0].Selected, "A2");
+
+                       dgv.Columns[0].Selected = true;
+                       Assert.AreEqual (false, dgv.Rows[0].Cells[0].Selected, "A3");
+
+                       dgv.Rows[0].Selected = true;
+                       Assert.AreEqual (true, dgv.Rows[0].Cells[0].Selected, "A4");
+
+                       dgv.Rows[0].Cells[0].Selected = false;
+                       Assert.AreEqual (false, dgv.Rows[0].Cells[0].Selected, "A5");
+
+                       dgv.Rows[0].Selected = false;
+                       Assert.AreEqual (false, dgv.Rows[0].Cells[0].Selected, "A6");
+
+                       dgv.Rows[0].Cells[0].Selected = true;
+                       Assert.AreEqual (true, dgv.Rows[0].Cells[0].Selected, "A7");
+               }
+
+               /* The height of a cell (row) is based on Font
+               [Test]
+               public void Size ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (new Size (-1, -1), c.Size, "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreEqual (new Size (100, 22), dgv.Rows[0].Cells[0].Size, "A2");
+                       
+                       // Does not resize to content
+                       dgv.Rows[0].Cells[0].Value = "bob";
+                       Assert.AreEqual (new Size (100, 22), dgv.Rows[0].Cells[0].Size, "A3");
+               }
+               */
+
+               [Test]
+               public void Style ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (DataGridViewContentAlignment.NotSet, c.Style.Alignment, "A1");
+                       Assert.AreEqual (Color.Empty, c.Style.BackColor, "A2");
+                       Assert.AreEqual (DBNull.Value, c.Style.DataSourceNullValue, "A3");
+                       Assert.AreEqual (null, c.Style.Font, "A4");
+                       Assert.AreEqual (Color.Empty, c.Style.ForeColor, "A5");
+                       Assert.AreEqual (string.Empty, c.Style.Format, "A6");
+                       Assert.AreEqual (Thread.CurrentThread.CurrentCulture, c.Style.FormatProvider, "A7");
+                       Assert.AreEqual (true, c.Style.IsDataSourceNullValueDefault, "A8");
+                       Assert.AreEqual (true, c.Style.IsFormatProviderDefault, "A9");
+                       Assert.AreEqual (true, c.Style.IsNullValueDefault, "A10");
+                       Assert.AreEqual (string.Empty, c.Style.NullValue, "A11");
+                       Assert.AreEqual (Padding.Empty, c.Style.Padding, "A12");
+                       Assert.AreEqual (Color.Empty, c.Style.SelectionBackColor, "A13");
+                       Assert.AreEqual (Color.Empty, c.Style.SelectionForeColor, "A14");
+                       Assert.AreEqual (null, c.Style.Tag, "A15");
+                       Assert.AreEqual (DataGridViewTriState.NotSet, c.Style.WrapMode, "A16");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       // Style does not change based on parent
+                       // (InheritedStyle does)
+                       Assert.AreEqual (DataGridViewContentAlignment.NotSet, c.Style.Alignment, "A17");
+                       Assert.AreEqual (Color.Empty, c.Style.BackColor, "A18");
+                       Assert.AreEqual (DBNull.Value, c.Style.DataSourceNullValue, "A19");
+                       Assert.AreEqual (null, c.Style.Font, "A20");
+                       Assert.AreEqual (Color.Empty, c.Style.ForeColor, "A21");
+                       Assert.AreEqual (string.Empty, c.Style.Format, "A22");
+                       Assert.AreEqual (Thread.CurrentThread.CurrentCulture, c.Style.FormatProvider, "A23");
+                       Assert.AreEqual (true, c.Style.IsDataSourceNullValueDefault, "A24");
+                       Assert.AreEqual (true, c.Style.IsFormatProviderDefault, "A25");
+                       Assert.AreEqual (true, c.Style.IsNullValueDefault, "A26");
+                       Assert.AreEqual (string.Empty, c.Style.NullValue, "A27");
+                       Assert.AreEqual (Padding.Empty, c.Style.Padding, "A28");
+                       Assert.AreEqual (Color.Empty, c.Style.SelectionBackColor, "A29");
+                       Assert.AreEqual (Color.Empty, c.Style.SelectionForeColor, "A30");
+                       Assert.AreEqual (null, c.Style.Tag, "A31");
+                       Assert.AreEqual (DataGridViewTriState.NotSet, c.Style.WrapMode, "A32");
+               }
+
+               [Test]
+               public void Tag ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (null, c.Tag, "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreEqual (null, dgv.Rows[0].Cells[0].Tag, "A2");
+
+                       dgv.Rows[0].Cells[0].Tag = "bob";
+                       Assert.AreEqual ("bob", dgv.Rows[0].Cells[0].Tag, "A3");
+               }
+
+               [Test]
+               public void ToolTipText ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (string.Empty, c.ToolTipText, "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreEqual (string.Empty, dgv.Rows[0].Cells[0].ToolTipText, "A2");
+
+                       dgv.Rows[0].Cells[0].ToolTipText = "bob";
+                       Assert.AreEqual ("bob", dgv.Rows[0].Cells[0].ToolTipText, "A3");
+               }
+
+               [Test]
+               public void Value2 ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (null, c.Value, "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreEqual (null, dgv.Rows[0].Cells[0].Value, "A2");
+
+                       dgv.Rows[0].Cells[0].Value = "bob";
+                       Assert.AreEqual ("bob", dgv.Rows[0].Cells[0].Value, "A3");
+               }
+
+               [Test]
+               public void ValueType ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (typeof (Image), c.ValueType, "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreEqual (typeof (Image), dgv.Rows[0].Cells[0].ValueType, "A2");
+
+                       dgv.Rows[0].Cells[0].ValueType = typeof (bool);
+                       Assert.AreEqual (typeof (bool), dgv.Rows[0].Cells[0].ValueType, "A3");
+               }
+
+               [Test]
+               public void Visible ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (false, c.Visible, "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreEqual (true, dgv.Rows[0].Cells[0].Visible, "A2");
+
+                       dgv.Columns[0].Visible = false;
+                       Assert.AreEqual (false, dgv.Rows[0].Cells[0].Visible, "A3");
+
+                       dgv.Columns[0].Visible = true;
+                       Assert.AreEqual (true, dgv.Rows[0].Cells[0].Visible, "A4");
+
+                       dgv.Rows[0].Visible = false;
+                       Assert.AreEqual (false, dgv.Rows[0].Cells[0].Visible, "A5");
+
+                       dgv.Rows[0].Visible = true;
+                       Assert.AreEqual (true, dgv.Rows[0].Cells[0].Visible, "A6");
+               }
+
+               [Test]
+               public void MethodBorderWidths ()
+               {
+                       BaseCell c = new BaseCell ();
+
+                       DataGridViewAdvancedBorderStyle style = new DataGridViewAdvancedBorderStyle ();
+                       style.Bottom = DataGridViewAdvancedCellBorderStyle.Inset;
+                       style.Left = DataGridViewAdvancedCellBorderStyle.InsetDouble;
+                       style.Top = DataGridViewAdvancedCellBorderStyle.None;
+                       //style.Right = DataGridViewAdvancedCellBorderStyle.NotSet;
+
+                       Assert.AreEqual (new Rectangle (2, 0, 0, 1), c.PublicBorderWidths (style), "A1");
+
+                       style.Bottom = DataGridViewAdvancedCellBorderStyle.Outset;
+                       style.Left = DataGridViewAdvancedCellBorderStyle.OutsetDouble;
+                       style.Right = DataGridViewAdvancedCellBorderStyle.OutsetPartial;
+                       style.Top = DataGridViewAdvancedCellBorderStyle.Single;
+
+                       Assert.AreEqual (new Rectangle (2, 1, 1, 1), c.PublicBorderWidths (style), "A2");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       dgv.Rows[0].DividerHeight = 3;
+                       dgv.Columns[0].DividerWidth = 5;
+
+                       Assert.AreEqual (new Rectangle (2, 1, 6, 4), (dgv.Rows[0].Cells[0] as BaseCell).PublicBorderWidths (style), "A3");
+               }
+
+               /* Font measurement dependent
+               [Test]
+               public void MethodGetContentBounds ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (Rectangle.Empty, c.GetContentBounds (c.RowIndex), "A1");
+                       c.Value = "hello there";
+                       
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreEqual (new Rectangle (0, 2, 14, 16), dgv.Rows[0].Cells[0].GetContentBounds (dgv.Rows[0].Cells[0].RowIndex), "A2");
+
+                       dgv.Rows[0].Cells[0].Value = new Bitmap (20, 20);
+                       Assert.AreEqual (new Rectangle (0, 0, 20, 20), dgv.Rows[0].Cells[0].GetContentBounds (dgv.Rows[0].Cells[0].RowIndex), "A3");
+
+                       dgv.Rows[0].Cells[0].Value = new Bitmap (32, 32);
+                       Assert.AreEqual (new Rectangle (0, -5, 32, 32), dgv.Rows[0].Cells[0].GetContentBounds (dgv.Rows[0].Cells[0].RowIndex), "A3");
+               }
+               
+               [Test]
+               public void MethodGetContentBoundsOverload ()
+               {
+                       Bitmap b = new Bitmap (1, 1);
+                       Graphics g = Graphics.FromImage (b);
+
+                       BaseCell c = new BaseCell ();
+                       Assert.AreEqual (Rectangle.Empty, c.PublicGetContentBounds (g, c.Style, c.RowIndex), "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreEqual (new Rectangle (0, 2, 14, 16), (dgv.Rows[0].Cells[0] as BaseCell).PublicGetContentBounds (g, dgv.Rows[0].Cells[0].InheritedStyle, dgv.Rows[0].Cells[0].RowIndex), "A2");
+                       g.Dispose ();
+                       b.Dispose ();
+               }
+               */
+
+               [Test]
+               public void MethodGetErrorIconBounds ()
+               {
+                       Bitmap b = new Bitmap (1, 1);
+                       Graphics g = Graphics.FromImage (b);
+
+                       BaseCell c = new BaseCell ();
+                       Assert.AreEqual (Rectangle.Empty, c.PublicGetErrorIconBounds (g, c.Style, c.RowIndex), "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreEqual (Rectangle.Empty, (dgv.Rows[0].Cells[0] as BaseCell).PublicGetErrorIconBounds (g, dgv.Rows[0].Cells[0].InheritedStyle, dgv.Rows[0].Cells[0].RowIndex), "A2");
+                       g.Dispose ();
+                       b.Dispose ();
+               }
+
+               [Test]
+               public void MethodGetErrorText ()
+               {
+                       Bitmap b = new Bitmap (1, 1);
+                       Graphics g = Graphics.FromImage (b);
+
+                       BaseCell c = new BaseCell ();
+                       Assert.AreEqual (string.Empty, c.PublicGetErrorText (c.RowIndex), "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreEqual (string.Empty, (dgv.Rows[0].Cells[0] as BaseCell).PublicGetErrorText (dgv.Rows[0].Cells[0].RowIndex), "A2");
+                       g.Dispose ();
+                       b.Dispose ();
+               }
+
+               [Test]
+               public void MethodKeyEntersEditMode ()
+               {
+                       string result = string.Empty;
+                       string expected = string.Empty;
+                       
+                       DataGridViewCell c = new BaseCell ();
+
+                       foreach (Keys k in Enum.GetValues (typeof (Keys)))
+                               if (c.KeyEntersEditMode (new KeyEventArgs (k)))
+                                       result += ((int)k).ToString () + ";";
+
+                       Assert.AreEqual (expected, result, "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       result = string.Empty;
+
+                       foreach (Keys k in Enum.GetValues (typeof (Keys)))
+                               if (dgv.Rows[0].Cells[0].KeyEntersEditMode (new KeyEventArgs (k)))
+                                       result += ((int)k).ToString () + ";";
+
+                       Assert.AreEqual (expected, result, "A2");
+
+                       result = string.Empty;
+                       dgv.EditMode = DataGridViewEditMode.EditOnEnter;
+
+                       foreach (Keys k in Enum.GetValues (typeof (Keys)))
+                               if (dgv.Rows[0].Cells[0].KeyEntersEditMode (new KeyEventArgs (k)))
+                                       result += ((int)k).ToString () + ";";
+
+                       Assert.AreEqual (expected, result, "A3");
+
+                       result = string.Empty;
+                       dgv.EditMode = DataGridViewEditMode.EditOnF2;
+
+                       foreach (Keys k in Enum.GetValues (typeof (Keys)))
+                               if (dgv.Rows[0].Cells[0].KeyEntersEditMode (new KeyEventArgs (k)))
+                                       result += ((int)k).ToString () + ";";
+
+                       Assert.AreEqual (expected, result, "A4");
+
+                       result = string.Empty;
+                       dgv.EditMode = DataGridViewEditMode.EditOnKeystroke;
+
+                       foreach (Keys k in Enum.GetValues (typeof (Keys)))
+                               if (dgv.Rows[0].Cells[0].KeyEntersEditMode (new KeyEventArgs (k)))
+                                       result += ((int)k).ToString () + ";";
+
+                       Assert.AreEqual (expected, result, "A5");
+
+                       result = string.Empty;
+                       dgv.EditMode = DataGridViewEditMode.EditProgrammatically;
+
+                       foreach (Keys k in Enum.GetValues (typeof (Keys)))
+                               if (dgv.Rows[0].Cells[0].KeyEntersEditMode (new KeyEventArgs (k)))
+                                       result += ((int)k).ToString () + ";";
+
+                       Assert.AreEqual (expected, result, "A6");
+               }
+
+               [Test]
+               public void MethodParseFormattedValue ()
+               {
+                       DataGridViewCell c = new FormattedBaseCell ();
+                       c.ValueType = typeof (bool);
+
+                       BooleanConverter bc = new BooleanConverter ();
+                       StringConverter sc = new StringConverter ();
+
+                       object o = c.ParseFormattedValue ("true", c.Style, sc, bc);
+                       Assert.AreEqual (true, (bool)o, "A1");
+               }
+
+               [Test]
+               public void MethodGetInheritedContextMenuStrip ()
+               {
+                       DataGridViewCell c = new BaseCell ();
+                       Assert.AreEqual (null, c.GetInheritedContextMenuStrip (c.RowIndex), "A1");
+
+                       DataGridView dgv = new DataGridView ();
+                       dgv.Columns.Add ("hi", "there");
+
+                       DataGridViewRow row = new DataGridViewRow ();
+                       row.Cells.Add (c);
+                       dgv.Rows.Add (row);
+
+                       Assert.AreEqual (null, dgv.Rows[0].Cells[0].GetInheritedContextMenuStrip (dgv.Rows[0].Cells[0].RowIndex), "A2");
+
+                       ContextMenuStrip cms1 = new ContextMenuStrip ();
+                       cms1.Items.Add ("Moose");
+                       dgv.ContextMenuStrip = cms1;
+
+                       Assert.AreSame (cms1, dgv.Rows[0].Cells[0].GetInheritedContextMenuStrip (dgv.Rows[0].Cells[0].RowIndex), "A3");
+
+                       ContextMenuStrip cms2 = new ContextMenuStrip ();
+                       cms2.Items.Add ("Moose");
+                       dgv.Columns[0].ContextMenuStrip = cms2;
+
+                       Assert.AreSame (cms2, dgv.Rows[0].Cells[0].GetInheritedContextMenuStrip (dgv.Rows[0].Cells[0].RowIndex), "A4");
+
+                       dgv.Rows[0].ContextMenuStrip = cms1;
+                       Assert.AreSame (cms1, dgv.Rows[0].Cells[0].GetInheritedContextMenuStrip (dgv.Rows[0].Cells[0].RowIndex), "A5");
+
+                       dgv.Rows[0].Cells[0].ContextMenuStrip = cms2;
+                       Assert.AreSame (cms2, dgv.Rows[0].Cells[0].GetInheritedContextMenuStrip (dgv.Rows[0].Cells[0].RowIndex), "A6");
+               }
+
+               private class FormattedBaseCell : DataGridViewImageCell
+               {
+                       public override Type FormattedValueType { get { return typeof (string); } }
+               }
+
+               private class BaseCell : DataGridViewImageCell
+               {
+                       public Rectangle PublicGetContentBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex)
+                       { return GetContentBounds (graphics, cellStyle, rowIndex); }
+                       public Rectangle PublicGetErrorIconBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex)
+                       { return GetErrorIconBounds (graphics, cellStyle, rowIndex); }
+                       public string PublicGetErrorText (int rowIndex)
+                       { return GetErrorText (rowIndex); }
+                       public Rectangle PublicBorderWidths (DataGridViewAdvancedBorderStyle advancedBorderStyle)
+                       { return BorderWidths (advancedBorderStyle); }
+               }
+
+       }
+}
+#endif