2007-03-19 Chris Toshok <toshok@ximian.com>
[mono-project.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / DataGridViewComboBoxColumn.cs
blob3136946760bb2e28c3867f5a3c28439cfed9e3df
1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
8 //
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 //
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
22 // Author:
23 // Pedro Martínez Juliá <pedromj@gmail.com>
27 #if NET_2_0
29 using System.ComponentModel;
30 using System.Drawing.Design;
32 namespace System.Windows.Forms {
34 [Designer ("System.Windows.Forms.Design.DataGridViewComboBoxColumnDesigner, " + Consts.AssemblySystem_Design,
35 "System.ComponentModel.Design.IDesigner")]
36 public class DataGridViewComboBoxColumn : DataGridViewColumn
38 private bool autoComplete;
39 private DataGridViewComboBoxDisplayStyle displayStyle;
40 private bool displayStyleForCurrentCellOnly;
41 private FlatStyle flatStyle;
43 public DataGridViewComboBoxColumn ()
45 CellTemplate = new DataGridViewComboBoxCell();
46 SortMode = DataGridViewColumnSortMode.NotSortable;
47 autoComplete = true;
48 displayStyle = DataGridViewComboBoxDisplayStyle.DropDownButton;
49 displayStyleForCurrentCellOnly = false;
52 [Browsable (true)]
53 [DefaultValue (true)]
54 public bool AutoComplete {
55 get { return autoComplete; }
56 set { autoComplete = value; }
59 [Browsable (false)]
60 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
61 public override DataGridViewCell CellTemplate {
62 get { return base.CellTemplate; }
63 set { base.CellTemplate = value as DataGridViewComboBoxCell; }
66 [AttributeProvider (typeof (IListSource))]
67 [DefaultValue (null)]
68 [RefreshProperties (RefreshProperties.Repaint)]
69 public object DataSource {
70 get {
71 if (base.CellTemplate == null) {
72 throw new InvalidOperationException("CellTemplate is null.");
74 return (base.CellTemplate as DataGridViewComboBoxCell).DataSource; }
75 set {
76 if (base.CellTemplate == null) {
77 throw new InvalidOperationException("CellTemplate is null.");
79 (base.CellTemplate as DataGridViewComboBoxCell).DataSource = value;
83 [Editor ("System.Windows.Forms.Design.DataMemberFieldEditor, " + Consts.AssemblySystem_Design,
84 "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
85 [DefaultValue ("")]
86 [TypeConverter ("System.Windows.Forms.Design.DataMemberFieldConverter, " + Consts.AssemblySystem_Design)]
87 public string DisplayMember {
88 get {
89 if (base.CellTemplate == null) {
90 throw new InvalidOperationException("CellTemplate is null.");
92 return (base.CellTemplate as DataGridViewComboBoxCell).DisplayMember;
94 set {
95 if (base.CellTemplate == null) {
96 throw new InvalidOperationException("CellTemplate is null.");
98 (base.CellTemplate as DataGridViewComboBoxCell).DisplayMember = value;
102 [DefaultValue (DataGridViewComboBoxDisplayStyle.DropDownButton)]
103 public DataGridViewComboBoxDisplayStyle DisplayStyle {
104 get { return displayStyle; }
105 set { displayStyle = value; }
108 [DefaultValue (false)]
109 public bool DisplayStyleForCurrentCellOnly {
110 get { return displayStyleForCurrentCellOnly; }
111 set { displayStyleForCurrentCellOnly = value; }
114 [DefaultValue (1)]
115 public int DropDownWidth {
116 get {
117 if (base.CellTemplate == null) {
118 throw new InvalidOperationException("CellTemplate is null.");
120 return (base.CellTemplate as DataGridViewComboBoxCell).DropDownWidth;
122 set {
123 if (value < 1) {
124 throw new ArgumentException("Value is less than 1.");
126 if (base.CellTemplate == null) {
127 throw new InvalidOperationException("CellTemplate is null.");
129 (base.CellTemplate as DataGridViewComboBoxCell).DropDownWidth = value;
133 [DefaultValue (FlatStyle.Standard)]
134 public FlatStyle FlatStyle {
135 get { return flatStyle; }
136 set { flatStyle = value; }
139 [Editor ("System.Windows.Forms.Design.StringCollectionEditor, " + Consts.AssemblySystem_Design,
140 "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
141 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
142 public DataGridViewComboBoxCell.ObjectCollection Items {
143 get {
144 if (base.CellTemplate == null) {
145 throw new InvalidOperationException("CellTemplate is null.");
147 return (base.CellTemplate as DataGridViewComboBoxCell).Items;
151 [DefaultValue (8)]
152 public int MaxDropDownItems {
153 get {
154 if (base.CellTemplate == null) {
155 throw new InvalidOperationException("CellTemplate is null.");
157 return (base.CellTemplate as DataGridViewComboBoxCell).MaxDropDownItems;
159 set {
160 if (base.CellTemplate == null) {
161 throw new InvalidOperationException("CellTemplate is null.");
163 (base.CellTemplate as DataGridViewComboBoxCell).MaxDropDownItems = value;
167 [DefaultValue (false)]
168 public bool Sorted {
169 get {
170 if (base.CellTemplate == null) {
171 throw new InvalidOperationException("CellTemplate is null.");
173 return (base.CellTemplate as DataGridViewComboBoxCell).Sorted;
175 set {
176 if (base.CellTemplate == null) {
177 throw new InvalidOperationException("CellTemplate is null.");
179 (base.CellTemplate as DataGridViewComboBoxCell).Sorted = value;
183 [DefaultValue ("")]
184 [Editor ("System.Windows.Forms.Design.DataMemberFieldEditor, " + Consts.AssemblySystem_Design,
185 "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
186 [TypeConverter ("System.Windows.Forms.Design.DataMemberFieldConverter, " + Consts.AssemblySystem_Design)]
187 public string ValueMember {
188 get {
189 if (base.CellTemplate == null) {
190 throw new InvalidOperationException("CellTemplate is null.");
192 return (base.CellTemplate as DataGridViewComboBoxCell).ValueMember;
194 set {
195 if (base.CellTemplate == null) {
196 throw new InvalidOperationException("CellTemplate is null.");
198 (base.CellTemplate as DataGridViewComboBoxCell).ValueMember = value;
202 public override object Clone ()
204 DataGridViewComboBoxColumn col = (DataGridViewComboBoxColumn) base.Clone();
205 col.autoComplete = this.autoComplete;
206 col.displayStyle = this.displayStyle;
207 col.displayStyleForCurrentCellOnly = this.displayStyleForCurrentCellOnly;
208 col.flatStyle = this.flatStyle;
209 col.CellTemplate = (DataGridViewComboBoxCell) this.CellTemplate.Clone();
210 return col;
213 public override string ToString ()
215 return GetType().Name;
222 #endif