Merge pull request #409 from Alkarex/patch-1
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / DataGridViewColumn.cs
index de61e7ab632cf926224967b7b5860e24108713ca..8b9e69b6c157849873fa8d90a0ddad4ae2e2cae7 100644 (file)
@@ -24,8 +24,6 @@
 //
 
 
-#if NET_2_0
-
 using System;
 using System.ComponentModel;
 
@@ -57,6 +55,7 @@ namespace System.Windows.Forms {
                private Type valueType;
                private bool visible = true;
                private int width = 100;
+               private int dataColumnIndex;
 
                private bool headerTextSet = false;
 
@@ -68,6 +67,7 @@ namespace System.Windows.Forms {
                        headerCell.SetColumnIndex(Index);
                        headerCell.Value = string.Empty;
                        displayIndex = -1;
+                       dataColumnIndex = -1;
                        dataPropertyName = string.Empty;
                        fillWeight = 100.0F;
                        sortMode = DataGridViewColumnSortMode.NotSortable;
@@ -182,6 +182,20 @@ namespace System.Windows.Forms {
                        }
                }
 
+               internal int DisplayIndexInternal {
+                       get { return DisplayIndex; }
+                       set { displayIndex = value; }
+               }
+
+               internal int DataColumnIndex {
+                       get { return dataColumnIndex; }
+                       set { 
+                               dataColumnIndex = value;
+                               if (dataColumnIndex >= 0)
+                                       isDataBound = true;
+                       }
+               }
+
                [DefaultValue (0)]
                public int DividerWidth {
                        get { return dividerWidth; }
@@ -453,6 +467,7 @@ Example */
                        */
                }
 
+               [MonoTODO("Actually calculate width")]
                public virtual int GetPreferredWidth (DataGridViewAutoSizeColumnMode autoSizeColumnMode, bool fixedHeight) {
                        switch (autoSizeColumnMode) {
                        case DataGridViewAutoSizeColumnMode.NotSet:
@@ -461,10 +476,10 @@ Example */
                                throw new ArgumentException("AutoSizeColumnMode is invalid");
                        }
                        if (fixedHeight) {
-                               return 0;
+                               return MinimumWidth;
                        }
                        else {
-                               return 0;
+                               return MinimumWidth;
                        }
                }
 
@@ -491,11 +506,6 @@ Example */
                        headerCell.SetColumnIndex(Index);
                }
 
-               internal void SetIsDataBound (bool value)
-               {
-                       isDataBound = value;
-               }
-               
                internal override void SetState (DataGridViewElementStates state) {
                        if (State != state) {
                                base.SetState(state);
@@ -512,4 +522,3 @@ Example */
        }
 }
 
-#endif