2007-01-10 Jonathan Pobst <jpobst@novell.com>
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / DataGridView.cs
index d09df900ebc5d1cad3ff436e2f7f374a738f9f07..eb1b1bce06ae86f617d3fcf941386a237d3e05e7 100644 (file)
@@ -39,9 +39,9 @@ namespace System.Windows.Forms {
        [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
        [Designer("System.Windows.Forms.Design.DataGridViewDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
        [Editor("System.Windows.Forms.Design.DataGridViewComponentEditor, " + Consts.AssemblySystem_Design, typeof (System.ComponentModel.ComponentEditor))]
-       // XXX System.ComponentModel.ComplexBindingPropertiesAttribute
+       [ComplexBindingProperties ("DataSource", "DataMember")]
        [DefaultEvent ("CellContentClick")]
-       // XXX [Docking (DockingBehavior.Ask)]
+       [Docking (DockingBehavior.Ask)]
        public class DataGridView : Control, ISupportInitialize, IBindableComponent, IDropTarget
        {
 
@@ -62,7 +62,6 @@ namespace System.Windows.Forms {
                private Color backColor;
                private Color backgroundColor;
                private Image backgroundImage;
-               private ImageLayout backgroundImageLayout;
                private BorderStyle borderStyle;
                private DataGridViewCellBorderStyle cellBorderStyle;
                private DataGridViewClipboardCopyMode clipboardCopyMode;
@@ -85,7 +84,7 @@ namespace System.Windows.Forms {
                private int firstDisplayedScrollingColumnHiddenWidth;
                private int firstDisplayedScrollingColumnIndex;
                private int firstDisplayedScrollingRowIndex;
-               private Color gridColor = Color.FromKnownColor(KnownColor.ControlDarkDark);
+               private Color gridColor = Color.FromKnownColor(KnownColor.ControlDark);
                private int horizontalScrollingOffset;
                private bool isCurrentCellDirty;
                //private bool isCurrentRowDirty;
@@ -112,7 +111,6 @@ namespace System.Windows.Forms {
                private Cursor userSetCursor;
                private int verticalScrollingOffset;
                private bool virtualMode;
-               private Size defaultSize;
                private HScrollBar horizontalScrollBar;
                private VScrollBar verticalScrollBar;
 
@@ -157,14 +155,21 @@ namespace System.Windows.Forms {
                        columns = CreateColumnsInstance();
                        columns.CollectionChanged += OnColumnCollectionChanged;
                        dataMember = String.Empty;
-                       defaultCellStyle = (DataGridViewCellStyle) columnHeadersDefaultCellStyle.Clone();
+                       defaultCellStyle = new DataGridViewCellStyle();
+                       defaultCellStyle.BackColor = SystemColors.Window;
+                       defaultCellStyle.ForeColor = SystemColors.ControlText;
+                       defaultCellStyle.SelectionBackColor = SystemColors.Highlight;
+                       defaultCellStyle.SelectionForeColor = SystemColors.HighlightText;
+                       defaultCellStyle.Font = this.Font;
+                       defaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
+                       defaultCellStyle.WrapMode = DataGridViewTriState.False;
                        editMode = DataGridViewEditMode.EditOnKeystrokeOrF2;
                        multiSelect = true;
                        readOnly = false;
                        rowHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
-                       rowHeadersDefaultCellStyle = (DataGridViewCellStyle) defaultCellStyle.Clone();
+                       rowHeadersDefaultCellStyle = (DataGridViewCellStyle) columnHeadersDefaultCellStyle.Clone ();
                        rowHeadersVisible = true;
-                       rowHeadersWidth = 43;
+                       rowHeadersWidth = 41;
                        rowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.EnableResizing;
                        rows = CreateRowsInstance();
                        rowsDefaultCellStyle = new DataGridViewCellStyle();
@@ -393,14 +398,9 @@ namespace System.Windows.Forms {
 
                [Browsable (false)]
                [EditorBrowsable (EditorBrowsableState.Never)]
-               public /* XXX override */ ImageLayout BackgroundImageLayout {
-                       get { return backgroundImageLayout; }
-                       set {
-                               if (backgroundImageLayout != value) {
-                                       backgroundImageLayout = value;
-                                       //OnBackgroundImageLayoutChanged(EventArg.Empty);
-                               }
-                       }
+               public override ImageLayout BackgroundImageLayout {
+                       get { return base.BackgroundImageLayout; }
+                       set { base.BackgroundImageLayout = value; }
                }
 
                [DefaultValue (BorderStyle.FixedSingle)]
@@ -444,7 +444,8 @@ namespace System.Windows.Forms {
                        get { return columns.Count; }
                        set {
                                if (value < 0) {
-                                       throw new ArgumentException("ColumnCount must be >= 0.");
+                                       throw new ArgumentOutOfRangeException("ColumnCount", 
+                                               "ColumnCount must be >= 0.");
                                }
                                if (dataSource != null) {
                                        throw new InvalidOperationException("Cant change column count if DataSource is set.");
@@ -492,7 +493,12 @@ namespace System.Windows.Forms {
                        set {
                                if (columnHeadersHeight != value) {
                                        if (value < 4) {
-                                               throw new ArgumentException("Column headers height cant be less than 4.");
+                                               throw new ArgumentOutOfRangeException("ColumnHeadersHeight", 
+                                                       "Column headers height cant be less than 4.");
+                                       }
+                                       if (value > 32768 ) {
+                                               throw new ArgumentOutOfRangeException("ColumnHeadersHeight", 
+                                                       "Column headers height cannot be more than 32768.");
                                        }
                                        columnHeadersHeight = value;
                                        OnColumnHeadersHeightChanged(EventArgs.Empty);
@@ -570,6 +576,7 @@ namespace System.Windows.Forms {
 
                [RefreshProperties (RefreshProperties.Repaint)]
                [DefaultValue (null)]
+               [AttributeProvider (typeof (IListSource))]
                // XXX AttributeProviderAtribute
                public object DataSource {
                        get { return dataSource; }
@@ -896,7 +903,12 @@ namespace System.Windows.Forms {
                        set {
                                if (rowHeadersWidth != value) {
                                        if (value < 4) {
-                                               throw new ArgumentException("RowHeadersWidth cant be less than 4.");
+                                               throw new ArgumentOutOfRangeException("RowHeadersWidth", 
+                                                       "Row headers width cant be less than 4.");
+                                       }
+                                       if (value > 32768 ) {
+                                               throw new ArgumentOutOfRangeException("RowHeadersWidth", 
+                                                       "Row headers width cannot be more than 32768.");
                                        }
                                        rowHeadersWidth = value;
                                        OnRowHeadersWidthChanged(EventArgs.Empty);
@@ -1069,8 +1081,8 @@ namespace System.Windows.Forms {
                [Browsable (false)]
                [EditorBrowsable (EditorBrowsableState.Never)]
                public override string Text {
-                       get { return base.text; }
-                       set { base.text = value; }
+                       get { return base.Text; }
+                       set { base.Text = value; }
                }
 
                [Browsable (false)]
@@ -1176,7 +1188,6 @@ namespace System.Windows.Forms {
                static object DefaultValuesNeededEvent = new object ();
                static object EditingControlShowingEvent = new object ();
                static object EditModeChangedEvent = new object ();
-               static object PaddingChangedEvent = new object ();
                static object GridColorChangedEvent = new object ();
                static object MultiSelectChangedEvent = new object ();
                static object NewRowNeededEvent = new object ();
@@ -1655,9 +1666,9 @@ namespace System.Windows.Forms {
                [Browsable (false)]
                [EditorBrowsable (EditorBrowsableState.Never)]
                [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
-               public event EventHandler PaddingChanged {
-                       add { Events.AddHandler (PaddingChangedEvent, value); }
-                       remove { Events.RemoveHandler (PaddingChangedEvent, value); }
+               public new event EventHandler PaddingChanged {
+                       add { base.PaddingChanged += value; }
+                       remove { base.PaddingChanged -= value; }
                }
 
                public event EventHandler GridColorChanged {
@@ -1888,7 +1899,7 @@ namespace System.Windows.Forms {
 
                [EditorBrowsable (EditorBrowsableState.Advanced)]
                public virtual DataGridViewAdvancedBorderStyle AdjustColumnHeaderBorderStyle (DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStyleInput, DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder, bool isFirstDisplayedColumn, bool isLastVisibleColumn) {
-                       return (DataGridViewAdvancedBorderStyle) dataGridViewAdvancedBorderStyleInput.Clone();
+                       return (DataGridViewAdvancedBorderStyle) ((ICloneable)dataGridViewAdvancedBorderStyleInput).Clone();
                }
 
                public bool AreAllCellsSelected (bool includeInvisibleCells) {
@@ -2162,11 +2173,18 @@ namespace System.Windows.Forms {
                        throw new NotImplementedException();
                }
 
-               public void UpdateCellErrorText (int columnIndex, int rowIndex) {
+               public void UpdateCellErrorText (int columnIndex, int rowIndex)
+               {
+                       throw new NotImplementedException();
+               }
+
+               public void UpdateCellValue (int columnIndex, int rowIndex)
+               {
                        throw new NotImplementedException();
                }
 
-               public void UpdateRowErrorText (int rowIndex) {
+               public void UpdateRowErrorText (int rowIndex)
+               {
                        throw new NotImplementedException();
                }
 
@@ -2179,7 +2197,7 @@ namespace System.Windows.Forms {
                }
 
                protected override Size DefaultSize {
-                       get { return defaultSize; }
+                       get { return new Size (240, 150); }
                }
 
                protected ScrollBar HorizontalScrollBar {
@@ -2190,6 +2208,11 @@ namespace System.Windows.Forms {
                        get { return verticalScrollBar; }
                }
 
+               protected virtual void AccessibilityNotifyCurrentCellChanged (Point cellAddress)
+               {
+                       throw new NotImplementedException ();
+               }
+
                protected void AutoResizeColumn (int columnIndex, DataGridViewAutoSizeColumnMode autoSizeColumnMode, bool fixedHeight) {
                        throw new NotImplementedException();
                }
@@ -2281,321 +2304,367 @@ namespace System.Windows.Forms {
                        }
                }
 
-               protected override AccessibleObject CreateAccessibilityInstance () {
+               protected override AccessibleObject CreateAccessibilityInstance ()
+               {
                        return new DataGridViewAccessibleObject(this);
                }
 
                [EditorBrowsable (EditorBrowsableState.Advanced)]
-               protected virtual DataGridViewColumnCollection CreateColumnsInstance () {
+               protected virtual DataGridViewColumnCollection CreateColumnsInstance ()
+               {
                        return new DataGridViewColumnCollection(this);
                }
 
-               protected override Control.ControlCollection CreateControlsInstance () {
+               protected override Control.ControlCollection CreateControlsInstance ()
+               {
                        return base.CreateControlsInstance(); //new Control.ControlCollection(this);
                }
 
                [EditorBrowsable (EditorBrowsableState.Advanced)]
-               protected virtual DataGridViewRowCollection CreateRowsInstance () {
+               protected virtual DataGridViewRowCollection CreateRowsInstance ()
+               {
                        return new DataGridViewRowCollection(this);
                }
 
                protected override void Dispose (bool disposing) {
                }
 
-               //protected override AccessibleObject GetAccessibilityObjectById (int objectId) {
-               protected AccessibleObject GetAccessibilityObjectById (int objectId) {
+               protected override AccessibleObject GetAccessibilityObjectById (int objectId)
+               {
                        throw new NotImplementedException();
                }
 
-               protected override bool IsInputChar (char charCode) {
+               protected override bool IsInputChar (char charCode)
+               {
                        return base.IsInputChar(charCode);
-                       //throw new NotImplementedException();
                }
 
-               protected override bool IsInputKey (Keys keyData) {
+               protected override bool IsInputKey (Keys keyData)
+               {
                        return base.IsInputKey(keyData);
-                       //throw new NotImplementedException();
                }
 
                protected virtual void OnAllowUserToAddRowsChanged (EventArgs e)
                {
                        EventHandler eh = (EventHandler)(Events [AllowUserToAddRowsChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnAllowUserToDeleteRowsChanged (EventArgs e)
                {
                        EventHandler eh = (EventHandler)(Events [AllowUserToDeleteRowsChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnAllowUserToOrderColumnsChanged (EventArgs e)
                {
                        EventHandler eh = (EventHandler)(Events [AllowUserToOrderColumnsChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnAllowUserToResizeColumnsChanged (EventArgs e)
                {
                        EventHandler eh = (EventHandler)(Events [AllowUserToResizeColumnsChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnAllowUserToResizeRowsChanged (EventArgs e)
                {
                        EventHandler eh = (EventHandler)(Events [AllowUserToResizeRowsChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnAlternatingRowsDefaultCellStyleChanged (EventArgs e)
                {
                        EventHandler eh = (EventHandler)(Events [AlternatingRowsDefaultCellStyleChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnAutoGenerateColumnsChanged (EventArgs e)
                {
                        EventHandler eh = (EventHandler)(Events [AutoGenerateColumnsChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnAutoSizeColumnModeChanged (DataGridViewAutoSizeColumnModeEventArgs e)
                {
                        DataGridViewAutoSizeColumnModeEventHandler eh = (DataGridViewAutoSizeColumnModeEventHandler)(Events [AutoSizeColumnModeChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnAutoSizeColumnsModeChanged (DataGridViewAutoSizeColumnsModeEventArgs e)
                {
                        DataGridViewAutoSizeColumnsModeEventHandler eh = (DataGridViewAutoSizeColumnsModeEventHandler)(Events [AutoSizeColumnsModeChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnAutoSizeRowsModeChanged (DataGridViewAutoSizeModeEventArgs e)
                {
                        DataGridViewAutoSizeModeEventHandler eh = (DataGridViewAutoSizeModeEventHandler)(Events [AutoSizeRowsModeChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnBackgroundColorChanged (EventArgs e)
                {
                        EventHandler eh = (EventHandler)(Events [BackgroundColorChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
-               protected override void OnBindingContextChanged (EventArgs e) {
+               protected override void OnBindingContextChanged (EventArgs e)
+               {
                        base.OnBindingContextChanged(e);
                }
 
                protected virtual void OnBorderStyleChanged (EventArgs e)
                {
                        EventHandler eh = (EventHandler)(Events [BorderStyleChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCancelRowEdit (QuestionEventArgs e) {
                        QuestionEventHandler eh = (QuestionEventHandler)(Events [CancelRowEditEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellBeginEdit (DataGridViewCellCancelEventArgs e)
                {
                        DataGridViewCellCancelEventHandler eh = (DataGridViewCellCancelEventHandler)(Events [CellBeginEditEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellBorderStyleChanged (EventArgs e)
                {
                        EventHandler eh = (EventHandler)(Events [CellBorderStyleChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellClick (DataGridViewCellEventArgs e)
                {
                        DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellClickEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellContentClick (DataGridViewCellEventArgs e)
                {
                        DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellContentClickEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellContentDoubleClick (DataGridViewCellEventArgs e)
                {
                        DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellContentDoubleClickEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellContextMenuStripChanged (DataGridViewCellEventArgs e)
                {
                        DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellContextMenuStripChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellContextMenuStripNeeded (DataGridViewCellContextMenuStripNeededEventArgs e)
                {
                        DataGridViewCellContextMenuStripNeededEventHandler eh = (DataGridViewCellContextMenuStripNeededEventHandler)(Events [CellContextMenuStripNeededEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellDoubleClick (DataGridViewCellEventArgs e)
                {
                        DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellDoubleClickEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellEndEdit (DataGridViewCellEventArgs e)
                {
                        DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellEndEditEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellEnter (DataGridViewCellEventArgs e)
                {
                        DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellEnterEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected internal virtual void OnCellErrorTextChanged (DataGridViewCellEventArgs e)
                {
                        DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellErrorTextChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellErrorTextNeeded (DataGridViewCellErrorTextNeededEventArgs e)
                {
                        DataGridViewCellErrorTextNeededEventHandler eh = (DataGridViewCellErrorTextNeededEventHandler)(Events [CellErrorTextNeededEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellFormatting (DataGridViewCellFormattingEventArgs e)
                {
                        DataGridViewCellFormattingEventHandler eh = (DataGridViewCellFormattingEventHandler)(Events [CellFormattingEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellLeave (DataGridViewCellEventArgs e)
                {
                        DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellLeaveEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellMouseClick (DataGridViewCellMouseEventArgs e)
                {
                        DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [CellMouseClickEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellMouseDoubleClick (DataGridViewCellMouseEventArgs e)
                {
                        DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [CellMouseDoubleClickEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellMouseDown (DataGridViewCellMouseEventArgs e)
                {
                        DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [CellMouseDownEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellMouseEnter (DataGridViewCellEventArgs e)
                {
                        DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellMouseEnterEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellMouseLeave (DataGridViewCellEventArgs e)
                {
                        DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellMouseLeaveEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellMouseMove (DataGridViewCellMouseEventArgs e)
                {
                        DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [CellMouseMoveEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellMouseUp (DataGridViewCellMouseEventArgs e)
                {
                        DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [CellMouseUpEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellPainting (DataGridViewCellPaintingEventArgs e)
                {
                        DataGridViewCellPaintingEventHandler eh = (DataGridViewCellPaintingEventHandler)(Events [CellPaintingEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected internal virtual void OnCellParsing (DataGridViewCellParsingEventArgs e)
                {
                        DataGridViewCellParsingEventHandler eh = (DataGridViewCellParsingEventHandler)(Events [CellParsingEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellStateChanged (DataGridViewCellStateChangedEventArgs e)
                {
                        DataGridViewCellStateChangedEventHandler eh = (DataGridViewCellStateChangedEventHandler)(Events [CellStateChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellStyleChanged (DataGridViewCellEventArgs e)
                {
                        DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellStyleChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellStyleContentChanged (DataGridViewCellStyleContentChangedEventArgs e) {
                        DataGridViewCellStyleContentChangedEventHandler eh = (DataGridViewCellStyleContentChangedEventHandler)(Events [CellStyleContentChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellToolTipTextChanged (DataGridViewCellEventArgs e) {
                        DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellToolTipTextChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
                                eh (this, e);
                }
 
                protected virtual void OnCellToolTipTextNeeded (DataGridViewCellToolTipTextNeededEventArgs e)
                {
                        DataGridViewCellToolTipTextNeededEventHandler eh = (DataGridViewCellToolTipTextNeededEventHandler)(Events [CellToolTipTextNeededEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellValidated (DataGridViewCellEventArgs e)
                {
                        DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellValidatedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
                                eh (this, e);
                }
 
                protected virtual void OnCellValidating (DataGridViewCellValidatingEventArgs e)
                {
                        DataGridViewCellValidatingEventHandler eh = (DataGridViewCellValidatingEventHandler)(Events [CellValidatingEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCellValueChanged (DataGridViewCellEventArgs e)
                {
                        DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellValueChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
                                eh (this, e);
                }
 
                protected virtual void OnCellValueNeeded (DataGridViewCellValueEventArgs e)
                {
                        DataGridViewCellValueEventHandler eh = (DataGridViewCellValueEventHandler)(Events [CellValueNeededEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
                                eh (this, e);
                }
 
                protected virtual void OnCellValuePushed (DataGridViewCellValueEventArgs e)
                {
                        DataGridViewCellValueEventHandler eh = (DataGridViewCellValueEventHandler)(Events [CellValuePushedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
                                eh (this, e);
                }
 
@@ -2609,139 +2678,167 @@ namespace System.Windows.Forms {
                protected internal virtual void OnColumnContextMenuStripChanged (DataGridViewColumnEventArgs e)
                {
                        DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnContextMenuStripChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected internal virtual void OnColumnDataPropertyNameChanged (DataGridViewColumnEventArgs e)
                {
                        DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnDataPropertyNameChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected internal virtual void OnColumnDefaultCellStyleChanged (DataGridViewColumnEventArgs e)
                {
                        DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnDefaultCellStyleChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected internal virtual void OnColumnDisplayIndexChanged (DataGridViewColumnEventArgs e)
                {
                        DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnDisplayIndexChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnColumnDividerDoubleClick (DataGridViewColumnDividerDoubleClickEventArgs e)
                {
                        DataGridViewColumnDividerDoubleClickEventHandler eh = (DataGridViewColumnDividerDoubleClickEventHandler)(Events [ColumnDividerDoubleClickEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected internal virtual void OnColumnDividerWidthChanged (DataGridViewColumnEventArgs e)
                {
                        DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnDividerWidthChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected internal virtual void OnColumnHeaderCellChanged (DataGridViewColumnEventArgs e)
                {
                        DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnHeaderCellChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnColumnHeaderMouseClick (DataGridViewCellMouseEventArgs e)
                {
                        DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [ColumnHeaderMouseClickEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnColumnHeaderMouseDoubleClick (DataGridViewCellMouseEventArgs e)
                {
                        DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [ColumnHeaderMouseDoubleClickEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnColumnHeadersBorderStyleChanged (EventArgs e)
                {
                        EventHandler eh = (EventHandler)(Events [ColumnHeadersBorderStyleChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnColumnHeadersDefaultCellStyleChanged (EventArgs e)
                {
                        EventHandler eh = (EventHandler)(Events [ColumnHeadersDefaultCellStyleChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnColumnHeadersHeightChanged (EventArgs e)
                {
                        EventHandler eh = (EventHandler)(Events [ColumnHeadersHeightChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnColumnHeadersHeightSizeModeChanged (DataGridViewAutoSizeModeEventArgs e)
                {
                        DataGridViewAutoSizeModeEventHandler eh = (DataGridViewAutoSizeModeEventHandler)(Events [ColumnHeadersHeightSizeModeChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected internal virtual void OnColumnMinimumWidthChanged (DataGridViewColumnEventArgs e)
                {
                        DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnMinimumWidthChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected internal virtual void OnColumnNameChanged (DataGridViewColumnEventArgs e)
                {
                        DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnNameChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnColumnRemoved (DataGridViewColumnEventArgs e)
                {
                        DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnRemovedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected internal virtual void OnColumnSortModeChanged (DataGridViewColumnEventArgs e)
                {
                        DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnSortModeChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected internal virtual void OnColumnStateChanged (DataGridViewColumnStateChangedEventArgs e)
                {
                        DataGridViewColumnStateChangedEventHandler eh = (DataGridViewColumnStateChangedEventHandler)(Events [ColumnStateChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected internal virtual void OnColumnToolTipTextChanged (DataGridViewColumnEventArgs e)
                {
                        DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnToolTipTextChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected internal virtual void OnColumnWidthChanged (DataGridViewColumnEventArgs e)
                {
                        DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnWidthChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCurrentCellChanged (EventArgs e)
                {
                        EventHandler eh = (EventHandler)(Events [CurrentCellChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnCurrentCellDirtyStateChanged (EventArgs e)
                {
                        EventHandler eh = (EventHandler)(Events [CurrentCellDirtyStateChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
+               }
+
+               protected override void OnCursorChanged (EventArgs e)
+               {
+                       base.OnCursorChanged (e);
                }
 
                protected virtual void OnDataBindingComplete (DataGridViewBindingCompleteEventArgs e)
                {
                        DataGridViewBindingCompleteEventHandler eh = (DataGridViewBindingCompleteEventHandler)(Events [DataBindingCompleteEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnDataError (bool displayErrorDialogIfNoHandler, DataGridViewDataErrorEventArgs e) {
@@ -2757,22 +2854,26 @@ namespace System.Windows.Forms {
                }
                protected virtual void OnDataMemberChanged (EventArgs e) {
                        EventHandler eh = (EventHandler)(Events [DataMemberChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnDataSourceChanged (EventArgs e) {
                        EventHandler eh = (EventHandler)(Events [DataSourceChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnDefaultCellStyleChanged (EventArgs e) {
                        EventHandler eh = (EventHandler)(Events [DefaultCellStyleChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnDefaultValuesNeeded (DataGridViewRowEventArgs e) {
                        DataGridViewRowEventHandler eh = (DataGridViewRowEventHandler)(Events [DefaultValuesNeededEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected override void OnDoubleClick (EventArgs e) {
@@ -2781,13 +2882,15 @@ namespace System.Windows.Forms {
 
                protected virtual void OnEditingControlShowing (DataGridViewEditingControlShowingEventArgs e) {
                        DataGridViewEditingControlShowingEventHandler eh = (DataGridViewEditingControlShowingEventHandler)(Events [EditingControlShowingEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected virtual void OnEditModeChanged (EventArgs e)
                {
                        EventHandler eh = (EventHandler)(Events [EditModeChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected override void OnEnabledChanged (EventArgs e)
@@ -2800,6 +2903,11 @@ namespace System.Windows.Forms {
                        base.OnEnter(e);
                }
 
+               protected override void OnGotFocus(EventArgs e)
+               {
+                       base.OnGotFocus (e);
+               }
+
                protected override void OnFontChanged (EventArgs e)
                {
                        base.OnFontChanged(e);
@@ -2813,7 +2921,8 @@ namespace System.Windows.Forms {
                protected virtual void OnGridColorChanged (EventArgs e)
                {
                        EventHandler eh = (EventHandler)(Events [GridColorChangedEvent]);
-                       if (eh != null) eh (this, e);
+                       if (eh != null)
+                               eh (this, e);
                }
 
                protected override void OnHandleCreated (EventArgs e)
@@ -2821,6 +2930,11 @@ namespace System.Windows.Forms {
                        base.OnHandleCreated(e);
                }
 
+               protected override void OnHandleDestroyed(EventArgs e)
+               {
+                       base.OnHandleDestroyed (e);
+               }
+
                [EditorBrowsable (EditorBrowsableState.Advanced)]
                protected override void OnKeyDown (KeyEventArgs e)
                {
@@ -2849,17 +2963,20 @@ namespace System.Windows.Forms {
                        base.OnLeave(e);
                }
 
-               //protected override void OnMouseClick (MouseEventArgs e)
-               protected void OnMouseClick (MouseEventArgs e)
+               protected override void OnLostFocus(EventArgs e)
+               {
+                       base.OnLostFocus (e);
+               }
+
+               protected override void OnMouseClick (MouseEventArgs e)
                {
-                       //base.OnMouseClick(e);
+                       base.OnMouseClick(e);
                        //Console.WriteLine("Mouse: Clicks: {0}; Delta: {1}; X: {2}; Y: {3};", e.Clicks, e.Delta, e.X, e.Y);
                }
 
-               //protected override void OnMouseDoubleClick (MouseEventArgs e)
-               protected void OnMouseDoubleClick (MouseEventArgs e)
+               protected override void OnMouseDoubleClick (MouseEventArgs e)
                {
-                       //base.OnMouseDoubleClick(e);
+                       base.OnMouseDoubleClick(e);
                }
 
                protected override void OnMouseDown (MouseEventArgs e)
@@ -2949,7 +3066,7 @@ namespace System.Windows.Forms {
 
                protected override void OnPaint (PaintEventArgs e) {
                        base.OnPaint(e);
-                       Console.WriteLine(e.ClipRectangle);
+                       //Console.WriteLine(e.ClipRectangle);
                        Rectangle bounds = ClientRectangle; //e.ClipRectangle;
                        e.Graphics.FillRectangle(new SolidBrush(backgroundColor), bounds);
                        Pen pen = new Pen(gridColor);
@@ -2973,7 +3090,7 @@ namespace System.Windows.Forms {
                                        headerBounds.Width = col.Width;
                                        DataGridViewCell cell = col.HeaderCell;
                                        DataGridViewCellStyle style = columnHeadersDefaultCellStyle;
-                                       DataGridViewAdvancedBorderStyle intermediateBorderStyle = (DataGridViewAdvancedBorderStyle) this.AdvancedColumnHeadersBorderStyle.Clone();;
+                                       DataGridViewAdvancedBorderStyle intermediateBorderStyle = (DataGridViewAdvancedBorderStyle) ((ICloneable)this.AdvancedColumnHeadersBorderStyle).Clone();
                                        DataGridViewAdvancedBorderStyle borderStyle = AdjustColumnHeaderBorderStyle(this.AdvancedColumnHeadersBorderStyle, intermediateBorderStyle, j == 0, j == columns.Count - 1);
                                        cell.InternalPaint(e.Graphics, e.ClipRectangle, headerBounds, cell.RowIndex, cell.State, cell.Value, cell.FormattedValue, cell.ErrorText, style, borderStyle, DataGridViewPaintParts.All);
                                        headerBounds.X += col.Width;
@@ -2990,7 +3107,7 @@ namespace System.Windows.Forms {
                                        rowHeaderBounds.Width = rowHeadersWidth;
                                        DataGridViewCell cell = row.HeaderCell;
                                        DataGridViewCellStyle style = rowHeadersDefaultCellStyle;
-                                       DataGridViewAdvancedBorderStyle intermediateBorderStyle = (DataGridViewAdvancedBorderStyle) this.AdvancedRowHeadersBorderStyle.Clone();;
+                                       DataGridViewAdvancedBorderStyle intermediateBorderStyle = (DataGridViewAdvancedBorderStyle) ((ICloneable)this.AdvancedRowHeadersBorderStyle).Clone();
                                        DataGridViewAdvancedBorderStyle borderStyle = cell.AdjustCellBorderStyle(this.AdvancedRowHeadersBorderStyle, intermediateBorderStyle, true, true, false, cell.RowIndex == 0);
                                        cell.InternalPaint(e.Graphics, e.ClipRectangle, rowHeaderBounds, cell.RowIndex, cell.State, cell.Value, cell.FormattedValue, cell.ErrorText, style, borderStyle, DataGridViewPaintParts.All);
                                        //e.Graphics.FillRectangle(new SolidBrush(rowHeadersDefaultCellStyle.BackColor), rowHeadersBounds);
@@ -3009,7 +3126,7 @@ namespace System.Windows.Forms {
                                                                cell.PositionEditingControl(true, true, bounds, e.ClipRectangle, style, false, false, (columns[currentCell.ColumnIndex].DisplayIndex == 0), (currentCell.RowIndex == 0));
                                                        }
                                                        else {
-                                                               DataGridViewAdvancedBorderStyle intermediateBorderStyle = (DataGridViewAdvancedBorderStyle) this.AdvancedCellBorderStyle.Clone();;
+                                                               DataGridViewAdvancedBorderStyle intermediateBorderStyle = (DataGridViewAdvancedBorderStyle) ((ICloneable)this.AdvancedCellBorderStyle).Clone();
                                                                DataGridViewAdvancedBorderStyle borderStyle = cell.AdjustCellBorderStyle(this.AdvancedCellBorderStyle, intermediateBorderStyle, true, true, j == 0, cell.RowIndex == 0);
                                                                OnCellFormatting(new DataGridViewCellFormattingEventArgs(cell.ColumnIndex, cell.RowIndex, cell.Value, cell.FormattedValueType, style));
                                                                DataGridViewCellPaintingEventArgs args = new DataGridViewCellPaintingEventArgs (this, e.Graphics, e.ClipRectangle, bounds, cell.RowIndex, cell.ColumnIndex, cell.State, cell.Value, cell.FormattedValue, cell.ErrorText, style, borderStyle, DataGridViewPaintParts.All);
@@ -3343,19 +3460,23 @@ namespace System.Windows.Forms {
                {
                }
 
-               protected bool ProcessAKey (Keys keyData) {
+               protected bool ProcessAKey (Keys keyData)
+               {
                        throw new NotImplementedException();
                }
 
-               protected bool ProcessDataGridViewKey (KeyEventArgs e) {
+               protected virtual bool ProcessDataGridViewKey (KeyEventArgs e)
+               {
                        throw new NotImplementedException();
                }
 
-               protected bool ProcessDeleteKey (Keys keyData) {
+               protected bool ProcessDeleteKey (Keys keyData)
+               {
                        throw new NotImplementedException();
                }
 
-               protected override bool ProcessDialogKey (Keys keyData) {
+               protected override bool ProcessDialogKey (Keys keyData)
+               {
                        return base.ProcessDialogKey(keyData);
                        //throw new NotImplementedException();
                }
@@ -3456,6 +3577,26 @@ namespace System.Windows.Forms {
                        base.WndProc(ref m);
                }
 
+               void IDropTarget.OnDragDrop (DragEventArgs e)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IDropTarget.OnDragEnter (DragEventArgs e)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IDropTarget.OnDragLeave (EventArgs e)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IDropTarget.OnDragOver (DragEventArgs e)
+               {
+                       throw new NotImplementedException ();
+               }
+
                internal void InternalOnCellClick (DataGridViewCellEventArgs e) {
                        OnCellClick(e);
                }