X11: improve handling of WS_EX_TOPMOST
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / DataGridViewComboBoxColumn.cs
index 5cbaca856c92dc2873f286a2a86af59a21735b8e..90af2ec2c695fd31846a843227515f9b3eb5c5c2 100644 (file)
@@ -23,9 +23,7 @@
 //     Pedro Martínez Juliá <pedromj@gmail.com>
 //
 
-
-#if NET_2_0
-
+using System.Collections;
 using System.ComponentModel;
 using System.Drawing.Design;
 using System.Drawing;
@@ -45,6 +43,7 @@ namespace System.Windows.Forms {
                public DataGridViewComboBoxColumn ()
                {
                        CellTemplate = new DataGridViewComboBoxCell();
+                       ((DataGridViewComboBoxCell) CellTemplate).OwningColumnTemplate = this;
                        SortMode = DataGridViewColumnSortMode.NotSortable;
                        autoComplete = true;
                        displayStyle = DataGridViewComboBoxDisplayStyle.DropDownButton;
@@ -62,7 +61,15 @@ namespace System.Windows.Forms {
                [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
                public override DataGridViewCell CellTemplate {
                        get { return base.CellTemplate; }
-                       set { base.CellTemplate = value as DataGridViewComboBoxCell; }
+                       set {
+
+                               DataGridViewComboBoxCell cellTemplate = value as DataGridViewComboBoxCell;
+                               if (cellTemplate == null)
+                                       throw new InvalidCastException ("Invalid cell tempalte type.");
+
+                               cellTemplate.OwningColumnTemplate = this;
+                               base.CellTemplate = cellTemplate;
+                       }
                }
 
                [AttributeProvider (typeof (IListSource))]
@@ -201,6 +208,20 @@ namespace System.Windows.Forms {
                        }
                }
 
+               internal void SyncItems (IList items)
+               {
+                       if (DataSource != null || DataGridView == null)
+                               return;
+
+                       for (int i = 0; i < DataGridView.RowCount; i++) {
+                               DataGridViewComboBoxCell comboCell = DataGridView.Rows[i].Cells[base.Index] as DataGridViewComboBoxCell;
+                               if (comboCell != null) {
+                                       comboCell.Items.ClearInternal ();
+                                       comboCell.Items.AddRangeInternal (this.Items);
+                               }
+                       }
+               }
+
                public override object Clone ()
                {
                        DataGridViewComboBoxColumn col = (DataGridViewComboBoxColumn) base.Clone();
@@ -220,5 +241,3 @@ namespace System.Windows.Forms {
        }
 
 }
-
-#endif