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:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
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)
23 // Pedro MartÃnez Juliá <pedromj@gmail.com>
29 using System.ComponentModel;
31 namespace System.Windows.Forms {
33 public class DataGridViewBand : DataGridViewElement, ICloneable, IDisposable {
35 private ContextMenuStrip contextMenuStrip = null;
36 private DataGridViewCellStyle defaultCellStyle;
37 private Type defaultHeaderCellType;
38 private bool displayed;
39 private bool frozen = false;
40 private int index = -1;
41 private bool readOnly = false;
42 private DataGridViewTriState resizable = DataGridViewTriState.True;
43 private bool selected = false;
44 private object tag = null;
45 private bool visible = true;
46 private DataGridViewHeaderCell headerCellCore;
48 private DataGridViewCellStyle inheritedStyle = null;
50 internal DataGridViewBand ()
60 public virtual ContextMenuStrip ContextMenuStrip {
61 get { return contextMenuStrip; }
62 set { contextMenuStrip = value; }
66 public virtual DataGridViewCellStyle DefaultCellStyle {
68 if (defaultCellStyle == null) {
69 defaultCellStyle = new DataGridViewCellStyle();
71 return defaultCellStyle;
73 set { defaultCellStyle = value; }
77 public Type DefaultHeaderCellType {
78 get { return defaultHeaderCellType; }
80 if (value.IsSubclassOf(typeof(DataGridViewHeaderCell))) {
81 throw new ArgumentException("Type is not DataGridViewHeaderCell or a derived type.");
83 defaultHeaderCellType = value;
88 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
89 public virtual bool Displayed {
90 get { return displayed; }
93 [DefaultValue (false)]
94 public virtual bool Frozen {
95 get { return frozen; }
96 set { frozen = value; }
100 public bool HasDefaultCellStyle {
101 get { return (defaultCellStyle != null); }
106 get { return index; }
110 public virtual DataGridViewCellStyle InheritedStyle {
111 get { return inheritedStyle; }
114 [DefaultValue (false)]
115 public virtual bool ReadOnly {
116 get { return readOnly; }
117 set { readOnly = value; }
121 public virtual DataGridViewTriState Resizable {
122 get { return resizable; }
123 set { resizable = value; }
127 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
128 public virtual bool Selected {
129 get { return selected; }
131 if (DataGridView == null) {
132 throw new InvalidOperationException("Cant select a row non associated with a DataGridView.");
139 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
145 [DefaultValue (true)]
146 public virtual bool Visible {
147 get { return visible; }
148 set { visible = value; }
151 public virtual object Clone ()
153 DataGridViewBand result = new DataGridViewBand();
154 //////////////////////////////
158 //public sealed void Dispose () {
159 public void Dispose ()
163 public override string ToString ()
165 return this.GetType().Name + ": " + index.ToString() + ".";
169 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
170 protected DataGridViewHeaderCell HeaderCellCore {
171 get { return headerCellCore; }
172 set { headerCellCore = value; }
175 protected bool IsRow {
176 get { return isRow; }
179 protected virtual void Dispose (bool disposing)
183 protected override void OnDataGridViewChanged ()
187 internal virtual void SetIndex (int index)