* DataGridViewElement.cs: Initialize state.
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / DataGridViewColumnHeaderCell.cs
index 48286259c2147ff3d048fdc83010a8253ccf4483..ae301720df93173932b02d0a1bd437b7cd156f1e 100644 (file)
 
 using System;
 using System.Drawing;
+using System.ComponentModel;
 
 namespace System.Windows.Forms {
 
        public class DataGridViewColumnHeaderCell : DataGridViewHeaderCell {
 
                private SortOrder sortGlyphDirection = SortOrder.None;
-
+               private object header_text;
+               
                public DataGridViewColumnHeaderCell () {
                }
 
+               [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
                public SortOrder SortGlyphDirection {
                        get { return sortGlyphDirection; }
                        set { sortGlyphDirection = value; }
@@ -47,7 +50,6 @@ namespace System.Windows.Forms {
                        return MemberwiseClone();
                }
 
-               /*
                public override ContextMenuStrip GetInheritedContextMenuStrip (int rowIndex) {
                        if (rowIndex != -1) {
                                throw new ArgumentOutOfRangeException("RowIndex is not -1");
@@ -57,10 +59,18 @@ namespace System.Windows.Forms {
                        }
                        return base.GetInheritedContextMenuStrip(rowIndex); //////////////////////////////
                }
-               */
 
                public override DataGridViewCellStyle GetInheritedStyle (DataGridViewCellStyle inheritedCellStyle, int rowIndex, bool includeColors) {
-                       throw new NotImplementedException();
+                       
+                       DataGridViewCellStyle result;
+                       
+                       if (HasStyle) {
+                               result = Style;
+                       } else {
+                               result = DataGridView.ColumnHeadersDefaultCellStyle;
+                       }
+                       
+                       return result;                  
                }
 
                public override string ToString () {
@@ -85,7 +95,13 @@ namespace System.Windows.Forms {
                }
 
                protected override object GetValue (int rowIndex) {
-                       throw new NotImplementedException();
+                       if (header_text != null)
+                               return header_text;
+                               
+                       if (OwningColumn != null)
+                               return OwningColumn.Name;
+                       
+                       return null;
                }
 
                protected override void Paint (Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates dataGridViewElementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) {
@@ -95,7 +111,8 @@ namespace System.Windows.Forms {
                }
 
                protected override bool SetValue (int rowIndex, object value) {
-                       throw new NotImplementedException();
+                       header_text = value;
+                       return true;
                }
 
                protected class DataGridViewColumnHeaderCellAccessibleObject : DataGridViewCellAccessibleObject {