X11: improve handling of WS_EX_TOPMOST
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / DataGridViewComboBoxColumn.cs
index ab1b4e8fd68fb74a35e888ccacc618e21318a63b..90af2ec2c695fd31846a843227515f9b3eb5c5c2 100644 (file)
 //     Pedro Martínez Juliá <pedromj@gmail.com>
 //
 
-
-#if NET_2_0
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing.Design;
+using System.Drawing;
 
 namespace System.Windows.Forms {
 
-       public class DataGridViewComboBoxColumn : DataGridViewColumn {
-
+       [ToolboxBitmap ("")]
+       [Designer ("System.Windows.Forms.Design.DataGridViewComboBoxColumnDesigner, " + Consts.AssemblySystem_Design,
+                  "System.ComponentModel.Design.IDesigner")]
+       public class DataGridViewComboBoxColumn : DataGridViewColumn
+       {
                private bool autoComplete;
                private DataGridViewComboBoxDisplayStyle displayStyle;
-               private bool displayStyleForCurrentCellsOnly;
+               private bool displayStyleForCurrentCellOnly;
                private FlatStyle flatStyle;
 
-               public DataGridViewComboBoxColumn () {
+               public DataGridViewComboBoxColumn ()
+               {
                        CellTemplate = new DataGridViewComboBoxCell();
+                       ((DataGridViewComboBoxCell) CellTemplate).OwningColumnTemplate = this;
                        SortMode = DataGridViewColumnSortMode.NotSortable;
                        autoComplete = true;
                        displayStyle = DataGridViewComboBoxDisplayStyle.DropDownButton;
-                       displayStyleForCurrentCellsOnly = false;
+                       displayStyleForCurrentCellOnly = false;
                }
 
+               [Browsable (true)]
+               [DefaultValue (true)]
                public bool AutoComplete {
                        get { return autoComplete; }
                        set { autoComplete = value; }
                }
 
+               [Browsable (false)]
+               [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))]
+               [DefaultValue (null)]
+               [RefreshProperties (RefreshProperties.Repaint)]
                public object DataSource {
                        get {
                                if (base.CellTemplate == null) {
@@ -67,6 +89,10 @@ namespace System.Windows.Forms {
                        }
                }
 
+               [Editor ("System.Windows.Forms.Design.DataMemberFieldEditor, " + Consts.AssemblySystem_Design,
+                        "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
+               [DefaultValue ("")]
+               [TypeConverter ("System.Windows.Forms.Design.DataMemberFieldConverter, " + Consts.AssemblySystem_Design)]
                public string DisplayMember {
                        get {
                                if (base.CellTemplate == null) {
@@ -82,16 +108,19 @@ namespace System.Windows.Forms {
                        }
                }
 
+               [DefaultValue (DataGridViewComboBoxDisplayStyle.DropDownButton)]
                public DataGridViewComboBoxDisplayStyle DisplayStyle {
                        get { return displayStyle; }
                        set { displayStyle = value; }
                }
 
-               public bool DisplayStyleForCurrentCellsOnly {
-                       get { return displayStyleForCurrentCellsOnly; }
-                       set { displayStyleForCurrentCellsOnly = value; }
+               [DefaultValue (false)]
+               public bool DisplayStyleForCurrentCellOnly {
+                       get { return displayStyleForCurrentCellOnly; }
+                       set { displayStyleForCurrentCellOnly = value; }
                }
 
+               [DefaultValue (1)]
                public int DropDownWidth {
                        get {
                                if (base.CellTemplate == null) {
@@ -110,11 +139,15 @@ namespace System.Windows.Forms {
                        }
                }
 
+               [DefaultValue (FlatStyle.Standard)]
                public FlatStyle FlatStyle {
                        get { return flatStyle; }
                        set { flatStyle = value; }
                }
 
+               [Editor ("System.Windows.Forms.Design.StringCollectionEditor, " + Consts.AssemblySystem_Design,
+                        "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
+               [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
                public DataGridViewComboBoxCell.ObjectCollection Items {
                        get {
                                if (base.CellTemplate == null) {
@@ -124,6 +157,7 @@ namespace System.Windows.Forms {
                        }
                }
 
+               [DefaultValue (8)]
                public int MaxDropDownItems {
                        get {
                                if (base.CellTemplate == null) {
@@ -139,6 +173,7 @@ namespace System.Windows.Forms {
                        }
                }
 
+               [DefaultValue (false)]
                public bool Sorted {
                        get {
                                if (base.CellTemplate == null) {
@@ -154,6 +189,10 @@ namespace System.Windows.Forms {
                        }
                }
 
+               [DefaultValue ("")]
+               [Editor ("System.Windows.Forms.Design.DataMemberFieldEditor, " + Consts.AssemblySystem_Design,
+                        "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
+               [TypeConverter ("System.Windows.Forms.Design.DataMemberFieldConverter, " + Consts.AssemblySystem_Design)]
                public string ValueMember {
                        get {
                                if (base.CellTemplate == null) {
@@ -169,22 +208,36 @@ namespace System.Windows.Forms {
                        }
                }
 
-               public override object Clone () {
+               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();
                        col.autoComplete = this.autoComplete;
                        col.displayStyle = this.displayStyle;
-                       col.displayStyleForCurrentCellsOnly = this.displayStyleForCurrentCellsOnly;
+                       col.displayStyleForCurrentCellOnly = this.displayStyleForCurrentCellOnly;
                        col.flatStyle = this.flatStyle;
                        col.CellTemplate = (DataGridViewComboBoxCell) this.CellTemplate.Clone();
                        return col;
                }
 
-               public override string ToString () {
+               public override string ToString ()
+               {
                        return GetType().Name;
                }
 
        }
 
 }
-
-#endif