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>
30 using System.ComponentModel;
31 using System.Runtime.InteropServices;
33 using System.Reflection;
34 using System.Collections;
36 namespace System.Windows.Forms {
38 [ComVisibleAttribute(true)]
39 [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
40 [Designer("System.Windows.Forms.Design.DataGridViewDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
41 [Editor("System.Windows.Forms.Design.DataGridViewComponentEditor, " + Consts.AssemblySystem_Design, typeof (System.ComponentModel.ComponentEditor))]
42 [ComplexBindingProperties ("DataSource", "DataMember")]
43 [DefaultEvent ("CellContentClick")]
44 [Docking (DockingBehavior.Ask)]
45 public class DataGridView : Control, ISupportInitialize, IBindableComponent, IDropTarget
48 private DataGridViewAdvancedBorderStyle adjustedTopLeftHeaderBorderStyle;
49 private DataGridViewAdvancedBorderStyle advancedCellBorderStyle;
50 private DataGridViewAdvancedBorderStyle advancedColumnHeadersBorderStyle;
51 private DataGridViewAdvancedBorderStyle advancedRowHeadersBorderStyle;
52 private bool allowUserToAddRows;
53 private bool allowUserToDeleteRows;
54 private bool allowUserToOrderColumns;
55 private bool allowUserToResizeColumns;
56 private bool allowUserToResizeRows;
57 private DataGridViewCellStyle alternatingRowsDefaultCellStyle;
58 private bool autoGenerateColumns;
59 private bool autoSize;
60 private DataGridViewAutoSizeColumnsMode autoSizeColumnsMode;
61 private DataGridViewAutoSizeRowsMode autoSizeRowsMode;
62 private Color backColor;
63 private Color backgroundColor;
64 private Image backgroundImage;
65 private BorderStyle borderStyle;
66 private DataGridViewCellBorderStyle cellBorderStyle;
67 private DataGridViewClipboardCopyMode clipboardCopyMode;
68 private DataGridViewHeaderBorderStyle columnHeadersBorderStyle;
69 private DataGridViewCellStyle columnHeadersDefaultCellStyle;
70 private int columnHeadersHeight;
71 private DataGridViewColumnHeadersHeightSizeMode columnHeadersHeightSizeMode;
72 private bool columnHeadersVisible;
73 private DataGridViewColumnCollection columns;
74 private DataGridViewCell currentCell;
75 private Point currentCellAddress;
76 private DataGridViewRow currentRow;
77 private string dataMember;
78 private object dataSource;
79 private DataGridViewCellStyle defaultCellStyle;
80 //private Control editingControl;
81 private DataGridViewEditMode editMode;
82 private bool enableHeadersVisualStyles;
83 private DataGridViewCell firstDisplayedCell;
84 private int firstDisplayedScrollingColumnHiddenWidth;
85 private int firstDisplayedScrollingColumnIndex;
86 private int firstDisplayedScrollingRowIndex;
87 private Color gridColor = Color.FromKnownColor(KnownColor.ControlDark);
88 private int horizontalScrollingOffset;
89 private bool isCurrentCellDirty;
90 //private bool isCurrentRowDirty;
91 private bool multiSelect;
92 private bool readOnly;
93 private DataGridViewHeaderBorderStyle rowHeadersBorderStyle;
94 private DataGridViewCellStyle rowHeadersDefaultCellStyle;
95 private bool rowHeadersVisible;
96 private int rowHeadersWidth;
97 private DataGridViewRowHeadersWidthSizeMode rowHeadersWidthSizeMode;
98 private DataGridViewRowCollection rows;
99 private DataGridViewCellStyle rowsDefaultCellStyle;
100 private DataGridViewRow rowTemplate;
101 private ScrollBars scrollBars;
102 private DataGridViewSelectionMode selectionMode;
103 private bool showCellErrors;
104 private bool showCellToolTips;
105 private bool showEditingIcon;
106 private bool showRowErrors;
107 private DataGridViewColumn sortedColumn = null;
108 private SortOrder sortOrder;
109 private bool standardTab;
110 private DataGridViewHeaderCell topLeftHeaderCell;
111 private Cursor userSetCursor;
112 private int verticalScrollingOffset;
113 private bool virtualMode;
114 private HScrollBar horizontalScrollBar;
115 private VScrollBar verticalScrollBar;
117 internal int gridWidth;
118 internal int gridHeight;
120 public DataGridView () {
121 adjustedTopLeftHeaderBorderStyle = new DataGridViewAdvancedBorderStyle();
122 adjustedTopLeftHeaderBorderStyle.All = DataGridViewAdvancedCellBorderStyle.Single;
123 advancedCellBorderStyle = new DataGridViewAdvancedBorderStyle();
124 advancedCellBorderStyle.All = DataGridViewAdvancedCellBorderStyle.Single;
125 advancedColumnHeadersBorderStyle = new DataGridViewAdvancedBorderStyle();
126 advancedColumnHeadersBorderStyle.All = DataGridViewAdvancedCellBorderStyle.Single;
127 advancedRowHeadersBorderStyle = new DataGridViewAdvancedBorderStyle();
128 advancedRowHeadersBorderStyle.All = DataGridViewAdvancedCellBorderStyle.Single;
129 alternatingRowsDefaultCellStyle = new DataGridViewCellStyle();
130 allowUserToAddRows = true;
131 allowUserToDeleteRows = true;
132 allowUserToOrderColumns = false;
133 allowUserToResizeColumns = true;
134 allowUserToResizeRows = true;
135 autoGenerateColumns = true;
136 autoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
137 autoSizeRowsMode = DataGridViewAutoSizeRowsMode.None;
138 backColor = Control.DefaultBackColor;
139 backgroundColor = SystemColors.AppWorkspace;
140 borderStyle = BorderStyle.FixedSingle;
141 cellBorderStyle = DataGridViewCellBorderStyle.None;
142 clipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithAutoHeaderText;
143 columnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
144 columnHeadersDefaultCellStyle = new DataGridViewCellStyle();
145 columnHeadersDefaultCellStyle.BackColor = SystemColors.Control;
146 columnHeadersDefaultCellStyle.ForeColor = SystemColors.WindowText;
147 columnHeadersDefaultCellStyle.SelectionBackColor = SystemColors.Highlight;
148 columnHeadersDefaultCellStyle.SelectionForeColor = SystemColors.HighlightText;
149 columnHeadersDefaultCellStyle.Font = this.Font;
150 columnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
151 columnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.True;
152 columnHeadersHeight = 23;
153 columnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing;
154 columnHeadersVisible = true;
155 columns = CreateColumnsInstance();
156 columns.CollectionChanged += OnColumnCollectionChanged;
157 dataMember = String.Empty;
158 defaultCellStyle = new DataGridViewCellStyle();
159 defaultCellStyle.BackColor = SystemColors.Window;
160 defaultCellStyle.ForeColor = SystemColors.ControlText;
161 defaultCellStyle.SelectionBackColor = SystemColors.Highlight;
162 defaultCellStyle.SelectionForeColor = SystemColors.HighlightText;
163 defaultCellStyle.Font = this.Font;
164 defaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
165 defaultCellStyle.WrapMode = DataGridViewTriState.False;
166 editMode = DataGridViewEditMode.EditOnKeystrokeOrF2;
169 rowHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
170 rowHeadersDefaultCellStyle = (DataGridViewCellStyle) columnHeadersDefaultCellStyle.Clone ();
171 rowHeadersVisible = true;
172 rowHeadersWidth = 41;
173 rowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.EnableResizing;
174 rows = CreateRowsInstance();
175 rowsDefaultCellStyle = new DataGridViewCellStyle();
176 selectionMode = DataGridViewSelectionMode.RowHeaderSelect;
177 showCellErrors = true;
178 showEditingIcon = true;
179 userSetCursor = Cursor.Current;
182 horizontalScrollBar = new HScrollBar();
183 horizontalScrollBar.Dock = DockStyle.Bottom;
184 horizontalScrollBar.Scroll += OnHScrollBarScroll;
185 horizontalScrollBar.Visible = false;
186 verticalScrollBar = new VScrollBar();
187 verticalScrollBar.Dock = DockStyle.Right;
188 verticalScrollBar.Scroll += OnVScrollBarScroll;
189 verticalScrollBar.Visible = false;
192 void ISupportInitialize.BeginInit ()
196 void ISupportInitialize.EndInit ()
203 [EditorBrowsable (EditorBrowsableState.Advanced)]
204 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
205 public virtual DataGridViewAdvancedBorderStyle AdjustedTopLeftHeaderBorderStyle {
206 get { return adjustedTopLeftHeaderBorderStyle; }
210 [EditorBrowsable (EditorBrowsableState.Advanced)]
211 public DataGridViewAdvancedBorderStyle AdvancedCellBorderStyle {
212 get { return advancedCellBorderStyle; }
216 [EditorBrowsable (EditorBrowsableState.Advanced)]
217 public DataGridViewAdvancedBorderStyle AdvancedColumnHeadersBorderStyle {
218 get { return advancedColumnHeadersBorderStyle; }
222 [EditorBrowsable (EditorBrowsableState.Advanced)]
223 public DataGridViewAdvancedBorderStyle AdvancedRowHeadersBorderStyle {
224 get { return advancedRowHeadersBorderStyle; }
227 [DefaultValue (true)]
228 public bool AllowUserToAddRows {
229 get { return allowUserToAddRows; }
231 if (allowUserToAddRows != value) {
232 allowUserToAddRows = value;
233 OnAllowUserToAddRowsChanged(EventArgs.Empty);
238 [DefaultValue (true)]
239 public bool AllowUserToDeleteRows {
240 get { return allowUserToDeleteRows; }
242 if (allowUserToDeleteRows != value) {
243 allowUserToDeleteRows = value;
244 OnAllowUserToDeleteRowsChanged(EventArgs.Empty);
249 [DefaultValue (false)]
250 public bool AllowUserToOrderColumns {
251 get { return allowUserToOrderColumns; }
253 if (allowUserToOrderColumns != value) {
254 allowUserToOrderColumns = value;
255 OnAllowUserToOrderColumnsChanged(EventArgs.Empty);
260 [DefaultValue (true)]
261 public bool AllowUserToResizeColumns {
262 get { return allowUserToResizeColumns; }
264 if (allowUserToResizeColumns != value) {
265 allowUserToResizeColumns = value;
266 OnAllowUserToResizeColumnsChanged(EventArgs.Empty);
271 [DefaultValue (true)]
272 public bool AllowUserToResizeRows {
273 get { return allowUserToResizeRows; }
275 if (allowUserToResizeRows != value) {
276 allowUserToResizeRows = value;
277 OnAllowUserToResizeRowsChanged(EventArgs.Empty);
282 public DataGridViewCellStyle AlternatingRowsDefaultCellStyle {
283 get { return alternatingRowsDefaultCellStyle; }
285 if (alternatingRowsDefaultCellStyle != value) {
286 alternatingRowsDefaultCellStyle = value;
287 OnAlternatingRowsDefaultCellStyleChanged(EventArgs.Empty);
294 [EditorBrowsable (EditorBrowsableState.Advanced)]
295 [DefaultValue (true)]
296 public bool AutoGenerateColumns {
297 get { return autoGenerateColumns; }
299 if (autoGenerateColumns != value) {
300 autoGenerateColumns = value;
301 OnAutoGenerateColumnsChanged(EventArgs.Empty);
306 public override bool AutoSize {
307 get { return autoSize; }
309 if (autoSize != value) {
311 //OnAutoSizeChanged(EventArgs.Empty);
316 [DefaultValue (DataGridViewAutoSizeColumnsMode.None)]
317 public DataGridViewAutoSizeColumnsMode AutoSizeColumnsMode {
318 get { return autoSizeColumnsMode; }
320 if (!Enum.IsDefined(typeof(DataGridViewAutoSizeColumnsMode), value)) {
321 throw new InvalidEnumArgumentException("Value is not valid DataGridViewAutoSizeColumnsMode.");
323 if (value == DataGridViewAutoSizeColumnsMode.ColumnHeader && columnHeadersVisible == false) {
324 foreach (DataGridViewColumn col in columns) {
325 if (col.AutoSizeMode == DataGridViewAutoSizeColumnMode.NotSet) {
326 throw new InvalidOperationException("Cant set this property to ColumnHeader in this DataGridView.");
330 if (value == DataGridViewAutoSizeColumnsMode.Fill) {
331 foreach (DataGridViewColumn col in columns) {
332 if (col.AutoSizeMode == DataGridViewAutoSizeColumnMode.NotSet) {
334 throw new InvalidOperationException("Cant set this property to Fill in this DataGridView.");
339 autoSizeColumnsMode = value;
343 [DefaultValue (DataGridViewAutoSizeRowsMode.None)]
344 public DataGridViewAutoSizeRowsMode AutoSizeRowsMode {
345 get { return autoSizeRowsMode; }
347 if (autoSizeRowsMode != value) {
348 if (!Enum.IsDefined(typeof(DataGridViewAutoSizeRowsMode), value)) {
349 throw new InvalidEnumArgumentException("Value is not valid DataGridViewRowsMode.");
351 if ((value == DataGridViewAutoSizeRowsMode.AllHeaders || value == DataGridViewAutoSizeRowsMode.DisplayedHeaders) && rowHeadersVisible == false) {
352 throw new InvalidOperationException("Cant set this property to AllHeaders or DisplayedHeaders in this DataGridView.");
354 autoSizeRowsMode = value;
355 OnAutoSizeRowsModeChanged(new DataGridViewAutoSizeModeEventArgs(false));
356 ////////////////////////////////////////////////////////////////
362 [EditorBrowsable (EditorBrowsableState.Never)]
363 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
364 public override Color BackColor {
365 get { return backColor; }
367 if (backColor != value) {
369 OnBackColorChanged(EventArgs.Empty);
374 public Color BackgroundColor {
375 get { return backgroundColor; }
377 if (backgroundColor != value) {
378 if (value == Color.Empty) {
379 throw new ArgumentException("Cant set an Empty color.");
381 backgroundColor = value;
382 OnBackgroundColorChanged(EventArgs.Empty);
388 [EditorBrowsable (EditorBrowsableState.Never)]
389 public override Image BackgroundImage {
390 get { return backgroundImage; }
392 if (backgroundImage != value) {
393 backgroundImage = value;
394 OnBackgroundImageChanged(EventArgs.Empty);
400 [EditorBrowsable (EditorBrowsableState.Never)]
401 public override ImageLayout BackgroundImageLayout {
402 get { return base.BackgroundImageLayout; }
403 set { base.BackgroundImageLayout = value; }
406 [DefaultValue (BorderStyle.FixedSingle)]
407 public BorderStyle BorderStyle {
408 get { return borderStyle; }
410 if (borderStyle != value) {
411 if (!Enum.IsDefined(typeof(BorderStyle), value)) {
412 throw new InvalidEnumArgumentException("Invalid border style.");
415 OnBorderStyleChanged(EventArgs.Empty);
421 [DefaultValue (DataGridViewCellBorderStyle.Single)]
422 public DataGridViewCellBorderStyle CellBorderStyle {
423 get { return cellBorderStyle; }
425 if (cellBorderStyle != value) {
426 cellBorderStyle = value;
427 OnCellBorderStyleChanged(EventArgs.Empty);
433 [DefaultValue (DataGridViewClipboardCopyMode.EnableWithAutoHeaderText)]
434 public DataGridViewClipboardCopyMode ClipboardCopyMode {
435 get { return clipboardCopyMode; }
436 set { clipboardCopyMode = value; }
440 [EditorBrowsable (EditorBrowsableState.Advanced)]
441 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
443 public int ColumnCount {
444 get { return columns.Count; }
447 throw new ArgumentOutOfRangeException("ColumnCount",
448 "ColumnCount must be >= 0.");
450 if (dataSource != null) {
451 throw new InvalidOperationException("Cant change column count if DataSource is set.");
453 if (value < columns.Count) {
454 for (int i = value; i < columns.Count; i++) {
458 else if (value > columns.Count) {
459 for (int i = 0; i < value; i++) {
460 DataGridViewColumn col = new DataGridViewColumn();
468 [DefaultValue (DataGridViewHeaderBorderStyle.Raised)]
469 public DataGridViewHeaderBorderStyle ColumnHeadersBorderStyle {
470 get { return columnHeadersBorderStyle; }
472 if (columnHeadersBorderStyle != value) {
473 columnHeadersBorderStyle = value;
474 OnColumnHeadersBorderStyleChanged(EventArgs.Empty);
479 [AmbientValue (null)]
480 public DataGridViewCellStyle ColumnHeadersDefaultCellStyle {
481 get { return columnHeadersDefaultCellStyle; }
483 if (columnHeadersDefaultCellStyle != value) {
484 columnHeadersDefaultCellStyle = value;
485 OnColumnHeadersDefaultCellStyleChanged(EventArgs.Empty);
491 public int ColumnHeadersHeight {
492 get { return columnHeadersHeight; }
494 if (columnHeadersHeight != value) {
496 throw new ArgumentOutOfRangeException("ColumnHeadersHeight",
497 "Column headers height cant be less than 4.");
499 if (value > 32768 ) {
500 throw new ArgumentOutOfRangeException("ColumnHeadersHeight",
501 "Column headers height cannot be more than 32768.");
503 columnHeadersHeight = value;
504 OnColumnHeadersHeightChanged(EventArgs.Empty);
509 [RefreshProperties (RefreshProperties.All)]
510 [DefaultValue (DataGridViewColumnHeadersHeightSizeMode.EnableResizing)]
511 public DataGridViewColumnHeadersHeightSizeMode ColumnHeadersHeightSizeMode {
512 get { return columnHeadersHeightSizeMode; }
514 if (columnHeadersHeightSizeMode != value) {
515 if (!Enum.IsDefined(typeof(DataGridViewColumnHeadersHeightSizeMode), value)) {
516 throw new InvalidEnumArgumentException("Value is not a valid DataGridViewColumnHeadersHeightSizeMode.");
518 columnHeadersHeightSizeMode = value;
519 OnColumnHeadersHeightSizeModeChanged(new DataGridViewAutoSizeModeEventArgs(false));
524 [DefaultValue (true)]
525 public bool ColumnHeadersVisible {
526 get { return columnHeadersVisible; }
527 set { columnHeadersVisible = value; }
530 [MergableProperty (false)]
531 [Editor ("System.Windows.Forms.Design.DataGridViewColumnCollectionEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
532 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
533 public DataGridViewColumnCollection Columns {
534 get { return columns; }
538 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
539 public DataGridViewCell CurrentCell {
540 get { return currentCell; }
542 /////////////////////////////////////////////////////
543 /// *** InvalidOperationException ***
544 /// Changes to the specified cell cannot be committed
545 /// to the data cache, or the new cell is in a hidden
547 /////////////////////////////////////////////////////
548 if (value.DataGridView != this) {
549 throw new ArgumentException("The cell is not in this DataGridView.");
556 public Point CurrentCellAddress {
557 get { return currentCellAddress; }
561 public DataGridViewRow CurrentRow {
562 get { return currentRow; }
566 [Editor ("System.Windows.Forms.Design.DataMemberListEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
567 public string DataMember {
568 get { return dataMember; }
570 if (dataMember != value) {
572 OnDataMemberChanged(EventArgs.Empty);
577 [RefreshProperties (RefreshProperties.Repaint)]
578 [DefaultValue (null)]
579 [AttributeProvider (typeof (IListSource))]
580 // XXX AttributeProviderAtribute
581 public object DataSource {
582 get { return dataSource; }
584 if (dataSource != value) {
585 /* The System.Windows.Forms.DataGridView class supports the standard Windows Forms data-binding model. This means the data source can be of any type that implements:
586 - the System.Collections.IList interface, including one-dimensional arrays.
587 - the System.ComponentModel.IListSource interface, such as the System.Data.DataTable and System.Data.DataSet classes.
588 - the System.ComponentModel.IBindingList interface, such as the System.ComponentModel.Collections.BindingList<> class.
589 - the System.ComponentModel.IBindingListView interface, such as the System.Windows.Forms.BindingSource class.
591 if (!(value is IList) && !(value is IListSource) && !(value is IBindingList) && !(value is IBindingListView)) {
592 throw new NotSupportedException("Type cant be binded.");
595 OnDataSourceChanged(EventArgs.Empty);
597 if (value is IList) {
598 BindIList(value as IList);
600 else if (value is IListSource) {
601 BindIListSource(value as IListSource);
603 else if (value is IBindingList) {
604 BindIBindingList(value as IBindingList);
606 else if (value is IBindingListView) {
607 BindIBindingListView(value as IBindingListView);
608 //bool cosa = ((value as IBindingListView).SortDescriptions as IList).IsFixedSize;
610 OnDataBindingComplete(new DataGridViewBindingCompleteEventArgs(ListChangedType.Reset));
615 [AmbientValue (null)]
616 public DataGridViewCellStyle DefaultCellStyle {
617 get { return defaultCellStyle; }
619 if (defaultCellStyle != value) {
620 defaultCellStyle = value;
621 OnDefaultCellStyleChanged(EventArgs.Empty);
626 public override Rectangle DisplayRectangle {
627 get { return base.DisplayRectangle; }
631 [EditorBrowsable (EditorBrowsableState.Advanced)]
632 public Control EditingControl {
634 if (currentCell == null || !currentCell.IsInEditMode) {
637 return (Control) Activator.CreateInstance(currentCell.EditType);
642 [EditorBrowsable (EditorBrowsableState.Advanced)]
643 public Panel EditingPanel {
644 get { throw new NotImplementedException(); }
647 [DefaultValue (DataGridViewEditMode.EditOnKeystrokeOrF2)]
648 public DataGridViewEditMode EditMode {
649 get { return editMode; }
651 if (editMode != value) {
653 OnEditModeChanged(EventArgs.Empty);
658 [DefaultValue (true)]
659 public bool EnableHeadersVisualStyles {
660 get { return enableHeadersVisualStyles; }
661 set { enableHeadersVisualStyles = value; }
665 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
666 public DataGridViewCell FirstDisplayedCell {
667 get { return firstDisplayedCell; }
669 if (value.DataGridView != this) {
670 throw new ArgumentException("The cell is not in this DataGridView.");
672 firstDisplayedCell = value;
677 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
678 [EditorBrowsable (EditorBrowsableState.Advanced)]
679 public int FirstDisplayedScrollingColumnHiddenWidth {
680 get { return firstDisplayedScrollingColumnHiddenWidth; }
684 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
685 public int FirstDisplayedScrollingColumnIndex {
686 get { return firstDisplayedScrollingColumnIndex; }
687 set { firstDisplayedScrollingColumnIndex = value; }
691 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
692 public int FirstDisplayedScrollingRowIndex {
693 get { return firstDisplayedScrollingRowIndex; }
694 set { firstDisplayedScrollingRowIndex = value; }
698 [EditorBrowsable (EditorBrowsableState.Advanced)]
699 public override Font Font {
700 get { return base.Font; }
701 set { base.Font = value; }
705 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
706 [EditorBrowsable (EditorBrowsableState.Advanced)]
707 public override Color ForeColor {
708 get { return base.ForeColor; }
709 set { base.ForeColor = value; }
712 public Color GridColor {
713 get { return gridColor; }
715 if (gridColor != value) {
716 if (value == Color.Empty) {
717 throw new ArgumentException("Cant set an Empty color.");
720 OnGridColorChanged(EventArgs.Empty);
726 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
727 public int HorizontalScrollingOffset {
728 get { return horizontalScrollingOffset; }
729 set { horizontalScrollingOffset = value; }
733 public bool IsCurrentCellDirty {
734 get { return isCurrentCellDirty; }
738 public bool IsCurrentCellInEditMode {
740 if (currentCell == null) {
743 return currentCell.IsInEditMode;
748 public bool IsCurrentRowDirty {
751 return IsCurrentCellDirty;
754 throw new NotImplementedException();
759 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
760 public DataGridViewCell this [int columnIndex, int rowIndex] {
761 get { return rows[rowIndex].Cells[columnIndex]; }
762 set { rows[rowIndex].Cells[columnIndex] = value; }
766 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
767 public DataGridViewCell this [string columnName, int rowIndex] {
769 int columnIndex = -1;
770 foreach (DataGridViewColumn col in columns) {
771 if (col.Name == columnName) {
772 columnIndex = col.Index;
776 return this[columnIndex, rowIndex];
779 int columnIndex = -1;
780 foreach (DataGridViewColumn col in columns) {
781 if (col.Name == columnName) {
782 columnIndex = col.Index;
786 this[columnIndex, rowIndex] = value;
790 [DefaultValue (true)]
791 public bool MultiSelect {
792 get { return multiSelect; }
794 if (multiSelect != value) {
796 OnMultiSelectChanged(EventArgs.Empty);
802 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
803 public int NewRowIndex {
805 if (!allowUserToAddRows) {
808 return rows.Count - 1;
813 [EditorBrowsable (EditorBrowsableState.Never)]
814 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
815 public new Padding Padding {
816 get { return Padding.Empty; }
821 [DefaultValue (false)]
822 public bool ReadOnly {
823 get { return readOnly; }
825 if (readOnly != value) {
827 OnReadOnlyChanged(EventArgs.Empty);
833 [EditorBrowsable (EditorBrowsableState.Advanced)]
834 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
836 public int RowCount {
837 get { return rows.Count; }
840 throw new ArgumentException("RowCount must be >= 0.");
842 if (value < 1 && allowUserToAddRows) {
843 throw new ArgumentException("RowCount must be >= 1 if AllowUserToAddRows is true.");
845 if (dataSource != null) {
846 throw new InvalidOperationException("Cant change row count if DataSource is set.");
848 if (value < rows.Count) {
849 for (int i = value; i < rows.Count; i++) {
853 else if (value > rows.Count) {
854 for (int i = 0; i < value; i++) {
855 // DataGridViewRow row = new DataGridViewRow(); //(DataGridViewRow) rowTemplate.Clone();
856 DataGridViewRow row = (DataGridViewRow) rowTemplate.Clone();
858 foreach (DataGridViewColumn col in columns) {
859 row.Cells.Add(col.CellTemplate.Clone() as DataGridViewCell);
863 if (ColumnCount == 0) {
864 ///////////////////////////////////////////////////////////////
865 //columns.Add(new DataGridViewTextBoxColumn());
866 throw new NotImplementedException();
872 [DefaultValue (DataGridViewHeaderBorderStyle.Raised)]
873 public DataGridViewHeaderBorderStyle RowHeadersBorderStyle {
874 get { return rowHeadersBorderStyle; }
876 if (rowHeadersBorderStyle != value) {
877 rowHeadersBorderStyle = value;
878 OnRowHeadersBorderStyleChanged(EventArgs.Empty);
883 [AmbientValue (null)]
884 public DataGridViewCellStyle RowHeadersDefaultCellStyle {
885 get { return rowHeadersDefaultCellStyle; }
887 if (rowHeadersDefaultCellStyle != value) {
888 rowHeadersDefaultCellStyle = value;
889 OnRowHeadersDefaultCellStyleChanged(EventArgs.Empty);
894 [DefaultValue (true)]
895 public bool RowHeadersVisible {
896 get { return rowHeadersVisible; }
897 set { rowHeadersVisible = value; }
901 public int RowHeadersWidth {
902 get { return rowHeadersWidth; }
904 if (rowHeadersWidth != value) {
906 throw new ArgumentOutOfRangeException("RowHeadersWidth",
907 "Row headers width cant be less than 4.");
909 if (value > 32768 ) {
910 throw new ArgumentOutOfRangeException("RowHeadersWidth",
911 "Row headers width cannot be more than 32768.");
913 rowHeadersWidth = value;
914 OnRowHeadersWidthChanged(EventArgs.Empty);
919 [RefreshProperties (RefreshProperties.All)]
920 [DefaultValue (DataGridViewRowHeadersWidthSizeMode.EnableResizing)]
921 public DataGridViewRowHeadersWidthSizeMode RowHeadersWidthSizeMode {
922 get { return rowHeadersWidthSizeMode; }
924 if (rowHeadersWidthSizeMode != value) {
925 if (!Enum.IsDefined(typeof(DataGridViewRowHeadersWidthSizeMode), value)) {
926 throw new InvalidEnumArgumentException("Value is not valid DataGridViewRowHeadersWidthSizeMode.");
928 rowHeadersWidthSizeMode = value;
929 OnRowHeadersWidthSizeModeChanged(new DataGridViewAutoSizeModeEventArgs(false));
935 public DataGridViewRowCollection Rows {
939 public DataGridViewCellStyle RowsDefaultCellStyle {
940 get { return rowsDefaultCellStyle; }
942 if (rowsDefaultCellStyle != value) {
943 rowsDefaultCellStyle = value;
944 OnRowsDefaultCellStyleChanged(EventArgs.Empty);
950 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
951 public DataGridViewRow RowTemplate {
953 if (rowTemplate == null) {
954 return new DataGridViewRow();
960 rowTemplate.SetDataGridView(this);
964 [DefaultValue (ScrollBars.Both)]
966 public ScrollBars ScrollBars {
967 get { return scrollBars; }
969 if (!Enum.IsDefined(typeof(ScrollBars), value)) {
970 throw new InvalidEnumArgumentException("Invalid ScrollBars value.");
972 ////////////////////////////////////////////////////////////
973 /// *** InvalidOperationException ***
974 /// The System.Windows.Forms.DataGridView is unable to
975 /// scroll due to a cell change that cannot be committed
977 ///////////////////////////////////////////////////////////
983 public DataGridViewSelectedCellCollection SelectedCells {
985 DataGridViewSelectedCellCollection selectedCells = new DataGridViewSelectedCellCollection();
986 foreach (DataGridViewRow row in rows) {
987 foreach (DataGridViewCell cell in row.Cells) {
989 selectedCells.InternalAdd(cell);
993 return selectedCells;
998 public DataGridViewSelectedColumnCollection SelectedColumns {
1000 DataGridViewSelectedColumnCollection selectedColumns = new DataGridViewSelectedColumnCollection();
1001 if (selectionMode == DataGridViewSelectionMode.FullColumnSelect || selectionMode == DataGridViewSelectionMode.ColumnHeaderSelect) {
1002 foreach (DataGridViewColumn col in columns) {
1004 selectedColumns.InternalAdd(col);
1008 return selectedColumns;
1013 public DataGridViewSelectedRowCollection SelectedRows {
1015 DataGridViewSelectedRowCollection selectedRows = new DataGridViewSelectedRowCollection();
1016 if (selectionMode == DataGridViewSelectionMode.FullColumnSelect || selectionMode == DataGridViewSelectionMode.RowHeaderSelect) {
1017 foreach (DataGridViewRow row in rows) {
1019 selectedRows.InternalAdd(row);
1023 return selectedRows;
1028 [DefaultValue (DataGridViewSelectionMode.RowHeaderSelect)]
1029 public DataGridViewSelectionMode SelectionMode {
1030 get { return selectionMode; }
1032 if (!Enum.IsDefined(typeof(DataGridViewSelectionMode), value)) {
1033 throw new InvalidEnumArgumentException("Value is not valid DataGridViewSelectionMode.");
1035 selectionMode = value;
1039 [DefaultValue (true)]
1040 public bool ShowCellErrors {
1041 get { return showCellErrors; }
1042 set { showCellErrors = value; }
1045 [DefaultValue (true)]
1046 public bool ShowCellToolTips {
1047 get { return showCellToolTips; }
1048 set { showCellToolTips = value; }
1051 [DefaultValue (true)]
1052 public bool ShowEditingIcon {
1053 get { return showEditingIcon; }
1054 set { showEditingIcon = value; }
1057 [DefaultValue (true)]
1058 public bool ShowRowErrors {
1059 get { return showRowErrors; }
1060 set { showRowErrors = value; }
1064 public DataGridViewColumn SortedColumn {
1065 get { return sortedColumn; }
1069 public SortOrder SortOrder {
1070 get { return sortOrder; }
1073 [DefaultValue (false)]
1074 [EditorBrowsable (EditorBrowsableState.Advanced)]
1075 public bool StandardTab {
1076 get { return standardTab; }
1077 set { standardTab = value; }
1082 [EditorBrowsable (EditorBrowsableState.Never)]
1083 public override string Text {
1084 get { return base.Text; }
1085 set { base.Text = value; }
1089 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
1090 public DataGridViewHeaderCell TopLeftHeaderCell {
1091 get { return topLeftHeaderCell; }
1092 set { topLeftHeaderCell = value; }
1096 [EditorBrowsable (EditorBrowsableState.Advanced)]
1097 public Cursor UserSetCursor {
1098 get { return userSetCursor; }
1102 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
1103 public int VerticalScrollingOffset {
1104 get { return verticalScrollingOffset; }
1107 [EditorBrowsable (EditorBrowsableState.Advanced)]
1108 [DefaultValue (false)]
1109 public bool VirtualMode {
1110 get { return virtualMode; }
1111 set { virtualMode = value; }
1114 static object AllowUserToAddRowsChangedEvent = new object ();
1115 static object AllowUserToDeleteRowsChangedEvent = new object ();
1116 static object AllowUserToOrderColumnsChangedEvent = new object ();
1117 static object AllowUserToResizeColumnsChangedEvent = new object ();
1118 static object AllowUserToResizeRowsChangedEvent = new object ();
1119 static object AlternatingRowsDefaultCellStyleChangedEvent = new object ();
1120 static object AutoGenerateColumnsChangedEvent = new object ();
1121 static object AutoSizeColumnModeChangedEvent = new object ();
1122 static object AutoSizeColumnsModeChangedEvent = new object ();
1123 static object AutoSizeRowsModeChangedEvent = new object ();
1124 static object BackgroundColorChangedEvent = new object ();
1125 static object BorderStyleChangedEvent = new object ();
1126 static object CancelRowEditEvent = new object ();
1127 static object CellBeginEditEvent = new object ();
1128 static object CellBorderStyleChangedEvent = new object ();
1129 static object CellClickEvent = new object ();
1130 static object CellContentClickEvent = new object ();
1131 static object CellContentDoubleClickEvent = new object ();
1132 static object CellContextMenuStripChangedEvent = new object ();
1133 static object CellContextMenuStripNeededEvent = new object ();
1134 static object CellDoubleClickEvent = new object ();
1135 static object CellEndEditEvent = new object ();
1136 static object CellEnterEvent = new object ();
1137 static object CellErrorTextChangedEvent = new object ();
1138 static object CellErrorTextNeededEvent = new object ();
1139 static object CellFormattingEvent = new object ();
1140 static object CellLeaveEvent = new object ();
1141 static object CellMouseClickEvent = new object ();
1142 static object CellMouseDoubleClickEvent = new object ();
1143 static object CellMouseDownEvent = new object ();
1144 static object CellMouseEnterEvent = new object ();
1145 static object CellMouseLeaveEvent = new object ();
1146 static object CellMouseMoveEvent = new object ();
1147 static object CellMouseUpEvent = new object ();
1148 static object CellPaintingEvent = new object ();
1149 static object CellParsingEvent = new object ();
1150 static object CellStateChangedEvent = new object ();
1151 static object CellStyleChangedEvent = new object ();
1152 static object CellStyleContentChangedEvent = new object ();
1153 static object CellToolTipTextChangedEvent = new object ();
1154 static object CellToolTipTextNeededEvent = new object ();
1155 static object CellValidatedEvent = new object ();
1156 static object CellValidatingEvent = new object ();
1157 static object CellValueChangedEvent = new object ();
1158 static object CellValueNeededEvent = new object ();
1159 static object CellValuePushedEvent = new object ();
1160 static object ColumnAddedEvent = new object ();
1161 static object ColumnContextMenuStripChangedEvent = new object ();
1162 static object ColumnDataPropertyNameChangedEvent = new object ();
1163 static object ColumnDefaultCellStyleChangedEvent = new object ();
1164 static object ColumnDisplayIndexChangedEvent = new object ();
1165 static object ColumnDividerDoubleClickEvent = new object ();
1166 static object ColumnDividerWidthChangedEvent = new object ();
1167 static object ColumnHeaderCellChangedEvent = new object ();
1168 static object ColumnHeaderMouseClickEvent = new object ();
1169 static object ColumnHeaderMouseDoubleClickEvent = new object ();
1170 static object ColumnHeadersBorderStyleChangedEvent = new object ();
1171 static object ColumnHeadersDefaultCellStyleChangedEvent = new object ();
1172 static object ColumnHeadersHeightChangedEvent = new object ();
1173 static object ColumnHeadersHeightSizeModeChangedEvent = new object ();
1174 static object ColumnMinimumWidthChangedEvent = new object ();
1175 static object ColumnNameChangedEvent = new object ();
1176 static object ColumnRemovedEvent = new object ();
1177 static object ColumnSortModeChangedEvent = new object ();
1178 static object ColumnStateChangedEvent = new object ();
1179 static object ColumnToolTipTextChangedEvent = new object ();
1180 static object ColumnWidthChangedEvent = new object ();
1181 static object CurrentCellChangedEvent = new object ();
1182 static object CurrentCellDirtyStateChangedEvent = new object ();
1183 static object DataBindingCompleteEvent = new object ();
1184 static object DataErrorEvent = new object ();
1185 static object DataMemberChangedEvent = new object ();
1186 static object DataSourceChangedEvent = new object ();
1187 static object DefaultCellStyleChangedEvent = new object ();
1188 static object DefaultValuesNeededEvent = new object ();
1189 static object EditingControlShowingEvent = new object ();
1190 static object EditModeChangedEvent = new object ();
1191 static object GridColorChangedEvent = new object ();
1192 static object MultiSelectChangedEvent = new object ();
1193 static object NewRowNeededEvent = new object ();
1194 static object ReadOnlyChangedEvent = new object ();
1195 static object RowContextMenuStripChangedEvent = new object ();
1196 static object RowContextMenuStripNeededEvent = new object ();
1197 static object RowDefaultCellStyleChangedEvent = new object ();
1198 static object RowDirtyStateNeededEvent = new object ();
1199 static object RowDividerDoubleClickEvent = new object ();
1200 static object RowDividerHeightChangedEvent = new object ();
1201 static object RowEnterEvent = new object ();
1202 static object RowErrorTextChangedEvent = new object ();
1203 static object RowErrorTextNeededEvent = new object ();
1204 static object RowHeaderCellChangedEvent = new object ();
1205 static object RowHeaderMouseClickEvent = new object ();
1206 static object RowHeaderMouseDoubleClickEvent = new object ();
1207 static object RowHeadersBorderStyleChangedEvent = new object ();
1208 static object RowHeadersDefaultCellStyleChangedEvent = new object ();
1209 static object RowHeadersWidthChangedEvent = new object ();
1210 static object RowHeadersWidthSizeModeChangedEvent = new object ();
1211 static object RowHeightChangedEvent = new object ();
1212 static object RowHeightInfoNeededEvent = new object ();
1213 static object RowHeightInfoPushedEvent = new object ();
1214 static object RowLeaveEvent = new object ();
1215 static object RowMinimumHeightChangedEvent = new object ();
1216 static object RowPostPaintEvent = new object ();
1217 static object RowPrePaintEvent = new object ();
1218 static object RowsAddedEvent = new object ();
1219 static object RowsDefaultCellStyleChangedEvent = new object ();
1220 static object RowsRemovedEvent = new object ();
1221 static object RowStateChangedEvent = new object ();
1222 static object RowUnsharedEvent = new object ();
1223 static object RowValidatedEvent = new object ();
1224 static object RowValidatingEvent = new object ();
1225 static object ScrollEvent = new object ();
1226 static object SelectionChangedEvent = new object ();
1227 static object SortCompareEvent = new object ();
1228 static object SortedEvent = new object ();
1229 static object UserAddedRowEvent = new object ();
1230 static object UserDeletedRowEvent = new object ();
1231 static object UserDeletingRowEvent = new object ();
1236 public event EventHandler AllowUserToAddRowsChanged {
1237 add { Events.AddHandler (AllowUserToAddRowsChangedEvent, value); }
1238 remove { Events.RemoveHandler (AllowUserToAddRowsChangedEvent, value); }
1241 public event EventHandler AllowUserToDeleteRowsChanged {
1242 add { Events.AddHandler (AllowUserToDeleteRowsChangedEvent, value); }
1243 remove { Events.RemoveHandler (AllowUserToDeleteRowsChangedEvent, value); }
1246 public event EventHandler AllowUserToOrderColumnsChanged {
1247 add { Events.AddHandler (AllowUserToOrderColumnsChangedEvent, value); }
1248 remove { Events.RemoveHandler (AllowUserToOrderColumnsChangedEvent, value); }
1251 public event EventHandler AllowUserToResizeColumnsChanged {
1252 add { Events.AddHandler (AllowUserToResizeColumnsChangedEvent, value); }
1253 remove { Events.RemoveHandler (AllowUserToResizeColumnsChangedEvent, value); }
1256 public event EventHandler AllowUserToResizeRowsChanged {
1257 add { Events.AddHandler (AllowUserToResizeRowsChangedEvent, value); }
1258 remove { Events.RemoveHandler (AllowUserToResizeRowsChangedEvent, value); }
1261 public event EventHandler AlternatingRowsDefaultCellStyleChanged {
1262 add { Events.AddHandler (AlternatingRowsDefaultCellStyleChangedEvent, value); }
1263 remove { Events.RemoveHandler (AlternatingRowsDefaultCellStyleChangedEvent, value); }
1267 [EditorBrowsable (EditorBrowsableState.Advanced)]
1268 public event EventHandler AutoGenerateColumnsChanged {
1269 add { Events.AddHandler (AutoGenerateColumnsChangedEvent, value); }
1270 remove { Events.RemoveHandler (AutoGenerateColumnsChangedEvent, value); }
1273 public event DataGridViewAutoSizeColumnModeEventHandler AutoSizeColumnModeChanged {
1274 add { Events.AddHandler (AutoSizeColumnModeChangedEvent, value); }
1275 remove { Events.RemoveHandler (AutoSizeColumnModeChangedEvent, value); }
1278 public event DataGridViewAutoSizeColumnsModeEventHandler AutoSizeColumnsModeChanged {
1279 add { Events.AddHandler (AutoSizeColumnsModeChangedEvent, value); }
1280 remove { Events.RemoveHandler (AutoSizeColumnsModeChangedEvent, value); }
1283 public event DataGridViewAutoSizeModeEventHandler AutoSizeRowsModeChanged {
1284 add { Events.AddHandler (AutoSizeRowsModeChangedEvent, value); }
1285 remove { Events.RemoveHandler (AutoSizeRowsModeChangedEvent, value); }
1289 [EditorBrowsable (EditorBrowsableState.Never)]
1290 public new event EventHandler BackColorChanged {
1291 add { base.BackColorChanged += value; }
1292 remove { base.BackColorChanged -= value; }
1295 public event EventHandler BackgroundColorChanged {
1296 add { Events.AddHandler (BackgroundColorChangedEvent, value); }
1297 remove { Events.RemoveHandler (BackgroundColorChangedEvent, value); }
1301 [EditorBrowsable (EditorBrowsableState.Never)]
1302 public new event EventHandler BackgroundImageChanged {
1303 add { base.BackgroundImageChanged += value; }
1304 remove { base.BackgroundImageChanged -= value; }
1308 [EditorBrowsable (EditorBrowsableState.Never)]
1309 public new event EventHandler BackgroundImageLayoutChanged; /* XXX {
1310 add { base.BackgroundImageLayoutChanged += value; }
1311 remove { base.BackgroundImageLayoutChanged -= value; }
1314 public event EventHandler BorderStyleChanged {
1315 add { Events.AddHandler (BorderStyleChangedEvent, value); }
1316 remove { Events.RemoveHandler (BorderStyleChangedEvent, value); }
1319 public event QuestionEventHandler CancelRowEdit {
1320 add { Events.AddHandler (CancelRowEditEvent, value); }
1321 remove { Events.RemoveHandler (CancelRowEditEvent, value); }
1324 public event DataGridViewCellCancelEventHandler CellBeginEdit {
1325 add { Events.AddHandler (CellBeginEditEvent, value); }
1326 remove { Events.RemoveHandler (CellBeginEditEvent, value); }
1329 public event EventHandler CellBorderStyleChanged {
1330 add { Events.AddHandler (CellBorderStyleChangedEvent, value); }
1331 remove { Events.RemoveHandler (CellBorderStyleChangedEvent, value); }
1334 public event DataGridViewCellEventHandler CellClick {
1335 add { Events.AddHandler (CellClickEvent, value); }
1336 remove { Events.RemoveHandler (CellClickEvent, value); }
1339 public event DataGridViewCellEventHandler CellContentClick {
1340 add { Events.AddHandler (CellContentClickEvent, value); }
1341 remove { Events.RemoveHandler (CellContentClickEvent, value); }
1344 public event DataGridViewCellEventHandler CellContentDoubleClick {
1345 add { Events.AddHandler (CellContentDoubleClickEvent, value); }
1346 remove { Events.RemoveHandler (CellContentDoubleClickEvent, value); }
1349 [EditorBrowsable (EditorBrowsableState.Advanced)]
1350 public event DataGridViewCellEventHandler CellContextMenuStripChanged {
1351 add { Events.AddHandler (CellContextMenuStripChangedEvent, value); }
1352 remove { Events.RemoveHandler (CellContextMenuStripChangedEvent, value); }
1355 [EditorBrowsable (EditorBrowsableState.Advanced)]
1356 public event DataGridViewCellContextMenuStripNeededEventHandler CellContextMenuStripNeeded {
1357 add { Events.AddHandler (CellContextMenuStripNeededEvent, value); }
1358 remove { Events.RemoveHandler (CellContextMenuStripNeededEvent, value); }
1361 public event DataGridViewCellEventHandler CellDoubleClick {
1362 add { Events.AddHandler (CellDoubleClickEvent, value); }
1363 remove { Events.RemoveHandler (CellDoubleClickEvent, value); }
1366 public event DataGridViewCellEventHandler CellEndEdit {
1367 add { Events.AddHandler (CellEndEditEvent, value); }
1368 remove { Events.RemoveHandler (CellEndEditEvent, value); }
1371 public event DataGridViewCellEventHandler CellEnter {
1372 add { Events.AddHandler (CellEnterEvent, value); }
1373 remove { Events.RemoveHandler (CellEnterEvent, value); }
1376 public event DataGridViewCellEventHandler CellErrorTextChanged {
1377 add { Events.AddHandler (CellErrorTextChangedEvent, value); }
1378 remove { Events.RemoveHandler (CellErrorTextChangedEvent, value); }
1381 [EditorBrowsable (EditorBrowsableState.Advanced)]
1382 public event DataGridViewCellErrorTextNeededEventHandler CellErrorTextNeeded {
1383 add { Events.AddHandler (CellErrorTextNeededEvent, value); }
1384 remove { Events.RemoveHandler (CellErrorTextNeededEvent, value); }
1387 public event DataGridViewCellFormattingEventHandler CellFormatting {
1388 add { Events.AddHandler (CellFormattingEvent, value); }
1389 remove { Events.RemoveHandler (CellFormattingEvent, value); }
1392 public event DataGridViewCellEventHandler CellLeave {
1393 add { Events.AddHandler (CellLeaveEvent, value); }
1394 remove { Events.RemoveHandler (CellLeaveEvent, value); }
1397 public event DataGridViewCellMouseEventHandler CellMouseClick {
1398 add { Events.AddHandler (CellMouseClickEvent, value); }
1399 remove { Events.RemoveHandler (CellMouseClickEvent, value); }
1402 public event DataGridViewCellMouseEventHandler CellMouseDoubleClick {
1403 add { Events.AddHandler (CellMouseDoubleClickEvent, value); }
1404 remove { Events.RemoveHandler (CellMouseDoubleClickEvent, value); }
1407 public event DataGridViewCellMouseEventHandler CellMouseDown {
1408 add { Events.AddHandler (CellMouseDownEvent, value); }
1409 remove { Events.RemoveHandler (CellMouseDownEvent, value); }
1412 public event DataGridViewCellEventHandler CellMouseEnter {
1413 add { Events.AddHandler (CellMouseEnterEvent, value); }
1414 remove { Events.RemoveHandler (CellMouseEnterEvent, value); }
1417 public event DataGridViewCellEventHandler CellMouseLeave {
1418 add { Events.AddHandler (CellMouseLeaveEvent, value); }
1419 remove { Events.RemoveHandler (CellMouseLeaveEvent, value); }
1422 public event DataGridViewCellMouseEventHandler CellMouseMove {
1423 add { Events.AddHandler (CellMouseMoveEvent, value); }
1424 remove { Events.RemoveHandler (CellMouseMoveEvent, value); }
1427 public event DataGridViewCellMouseEventHandler CellMouseUp {
1428 add { Events.AddHandler (CellMouseUpEvent, value); }
1429 remove { Events.RemoveHandler (CellMouseUpEvent, value); }
1432 public event DataGridViewCellPaintingEventHandler CellPainting {
1433 add { Events.AddHandler (CellPaintingEvent, value); }
1434 remove { Events.RemoveHandler (CellPaintingEvent, value); }
1437 public event DataGridViewCellParsingEventHandler CellParsing {
1438 add { Events.AddHandler (CellParsingEvent, value); }
1439 remove { Events.RemoveHandler (CellParsingEvent, value); }
1442 public event DataGridViewCellStateChangedEventHandler CellStateChanged {
1443 add { Events.AddHandler (CellStateChangedEvent, value); }
1444 remove { Events.RemoveHandler (CellStateChangedEvent, value); }
1447 public event DataGridViewCellEventHandler CellStyleChanged {
1448 add { Events.AddHandler (CellStyleChangedEvent, value); }
1449 remove { Events.RemoveHandler (CellStyleChangedEvent, value); }
1452 public event DataGridViewCellStyleContentChangedEventHandler CellStyleContentChanged {
1453 add { Events.AddHandler (CellStyleContentChangedEvent, value); }
1454 remove { Events.RemoveHandler (CellStyleContentChangedEvent, value); }
1457 public event DataGridViewCellEventHandler CellToolTipTextChanged {
1458 add { Events.AddHandler (CellToolTipTextChangedEvent, value); }
1459 remove { Events.RemoveHandler (CellToolTipTextChangedEvent, value); }
1462 [EditorBrowsable (EditorBrowsableState.Advanced)]
1463 public event DataGridViewCellToolTipTextNeededEventHandler CellToolTipTextNeeded {
1464 add { Events.AddHandler (CellToolTipTextNeededEvent, value); }
1465 remove { Events.RemoveHandler (CellToolTipTextNeededEvent, value); }
1468 public event DataGridViewCellEventHandler CellValidated {
1469 add { Events.AddHandler (CellValidatedEvent, value); }
1470 remove { Events.RemoveHandler (CellValidatedEvent, value); }
1473 public event DataGridViewCellValidatingEventHandler CellValidating {
1474 add { Events.AddHandler (CellValidatingEvent, value); }
1475 remove { Events.RemoveHandler (CellValidatingEvent, value); }
1478 public event DataGridViewCellEventHandler CellValueChanged {
1479 add { Events.AddHandler (CellValueChangedEvent, value); }
1480 remove { Events.RemoveHandler (CellValueChangedEvent, value); }
1483 [EditorBrowsable (EditorBrowsableState.Advanced)]
1484 public event DataGridViewCellValueEventHandler CellValueNeeded {
1485 add { Events.AddHandler (CellValueNeededEvent, value); }
1486 remove { Events.RemoveHandler (CellValueNeededEvent, value); }
1489 [EditorBrowsable (EditorBrowsableState.Advanced)]
1490 public event DataGridViewCellValueEventHandler CellValuePushed {
1491 add { Events.AddHandler (CellValuePushedEvent, value); }
1492 remove { Events.RemoveHandler (CellValuePushedEvent, value); }
1495 public event DataGridViewColumnEventHandler ColumnAdded {
1496 add { Events.AddHandler (ColumnAddedEvent, value); }
1497 remove { Events.RemoveHandler (ColumnAddedEvent, value); }
1500 public event DataGridViewColumnEventHandler ColumnContextMenuStripChanged {
1501 add { Events.AddHandler (ColumnContextMenuStripChangedEvent, value); }
1502 remove { Events.RemoveHandler (ColumnContextMenuStripChangedEvent, value); }
1505 public event DataGridViewColumnEventHandler ColumnDataPropertyNameChanged {
1506 add { Events.AddHandler (ColumnDataPropertyNameChangedEvent, value); }
1507 remove { Events.RemoveHandler (ColumnDataPropertyNameChangedEvent, value); }
1510 public event DataGridViewColumnEventHandler ColumnDefaultCellStyleChanged {
1511 add { Events.AddHandler (ColumnDefaultCellStyleChangedEvent, value); }
1512 remove { Events.RemoveHandler (ColumnDefaultCellStyleChangedEvent, value); }
1515 public event DataGridViewColumnEventHandler ColumnDisplayIndexChanged {
1516 add { Events.AddHandler (ColumnDisplayIndexChangedEvent, value); }
1517 remove { Events.RemoveHandler (ColumnDisplayIndexChangedEvent, value); }
1520 public event DataGridViewColumnDividerDoubleClickEventHandler ColumnDividerDoubleClick {
1521 add { Events.AddHandler (ColumnDividerDoubleClickEvent, value); }
1522 remove { Events.RemoveHandler (ColumnDividerDoubleClickEvent, value); }
1525 public event DataGridViewColumnEventHandler ColumnDividerWidthChanged {
1526 add { Events.AddHandler (ColumnDividerWidthChangedEvent, value); }
1527 remove { Events.RemoveHandler (ColumnDividerWidthChangedEvent, value); }
1530 public event DataGridViewColumnEventHandler ColumnHeaderCellChanged {
1531 add { Events.AddHandler (ColumnHeaderCellChangedEvent, value); }
1532 remove { Events.RemoveHandler (ColumnHeaderCellChangedEvent, value); }
1535 public event DataGridViewCellMouseEventHandler ColumnHeaderMouseClick {
1536 add { Events.AddHandler (ColumnHeaderMouseClickEvent, value); }
1537 remove { Events.RemoveHandler (ColumnHeaderMouseClickEvent, value); }
1540 public event DataGridViewCellMouseEventHandler ColumnHeaderMouseDoubleClick {
1541 add { Events.AddHandler (ColumnHeaderMouseDoubleClickEvent, value); }
1542 remove { Events.RemoveHandler (ColumnHeaderMouseDoubleClickEvent, value); }
1545 public event EventHandler ColumnHeadersBorderStyleChanged {
1546 add { Events.AddHandler (ColumnHeadersBorderStyleChangedEvent, value); }
1547 remove { Events.RemoveHandler (ColumnHeadersBorderStyleChangedEvent, value); }
1550 public event EventHandler ColumnHeadersDefaultCellStyleChanged {
1551 add { Events.AddHandler (ColumnHeadersDefaultCellStyleChangedEvent, value); }
1552 remove { Events.RemoveHandler (ColumnHeadersDefaultCellStyleChangedEvent, value); }
1555 public event EventHandler ColumnHeadersHeightChanged {
1556 add { Events.AddHandler (ColumnHeadersHeightChangedEvent, value); }
1557 remove { Events.RemoveHandler (ColumnHeadersHeightChangedEvent, value); }
1560 public event DataGridViewAutoSizeModeEventHandler ColumnHeadersHeightSizeModeChanged {
1561 add { Events.AddHandler (ColumnHeadersHeightSizeModeChangedEvent, value); }
1562 remove { Events.RemoveHandler (ColumnHeadersHeightSizeModeChangedEvent, value); }
1565 public event DataGridViewColumnEventHandler ColumnMinimumWidthChanged {
1566 add { Events.AddHandler (ColumnMinimumWidthChangedEvent, value); }
1567 remove { Events.RemoveHandler (ColumnMinimumWidthChangedEvent, value); }
1570 public event DataGridViewColumnEventHandler ColumnNameChanged {
1571 add { Events.AddHandler (ColumnNameChangedEvent, value); }
1572 remove { Events.RemoveHandler (ColumnNameChangedEvent, value); }
1575 public event DataGridViewColumnEventHandler ColumnRemoved {
1576 add { Events.AddHandler (ColumnRemovedEvent, value); }
1577 remove { Events.RemoveHandler (ColumnRemovedEvent, value); }
1580 public event DataGridViewColumnEventHandler ColumnSortModeChanged {
1581 add { Events.AddHandler (ColumnSortModeChangedEvent, value); }
1582 remove { Events.RemoveHandler (ColumnSortModeChangedEvent, value); }
1585 public event DataGridViewColumnStateChangedEventHandler ColumnStateChanged {
1586 add { Events.AddHandler (ColumnStateChangedEvent, value); }
1587 remove { Events.RemoveHandler (ColumnStateChangedEvent, value); }
1590 public event DataGridViewColumnEventHandler ColumnToolTipTextChanged {
1591 add { Events.AddHandler (ColumnToolTipTextChangedEvent, value); }
1592 remove { Events.RemoveHandler (ColumnToolTipTextChangedEvent, value); }
1595 public event DataGridViewColumnEventHandler ColumnWidthChanged {
1596 add { Events.AddHandler (ColumnWidthChangedEvent, value); }
1597 remove { Events.RemoveHandler (ColumnWidthChangedEvent, value); }
1600 public event EventHandler CurrentCellChanged {
1601 add { Events.AddHandler (CurrentCellChangedEvent, value); }
1602 remove { Events.RemoveHandler (CurrentCellChangedEvent, value); }
1605 [EditorBrowsable (EditorBrowsableState.Advanced)]
1606 public event EventHandler CurrentCellDirtyStateChanged {
1607 add { Events.AddHandler (CurrentCellDirtyStateChangedEvent, value); }
1608 remove { Events.RemoveHandler (CurrentCellDirtyStateChangedEvent, value); }
1611 public event DataGridViewBindingCompleteEventHandler DataBindingComplete {
1612 add { Events.AddHandler (DataBindingCompleteEvent, value); }
1613 remove { Events.RemoveHandler (DataBindingCompleteEvent, value); }
1616 public event DataGridViewDataErrorEventHandler DataError {
1617 add { Events.AddHandler (DataErrorEvent, value); }
1618 remove { Events.RemoveHandler (DataErrorEvent, value); }
1621 public event EventHandler DataMemberChanged {
1622 add { Events.AddHandler (DataMemberChangedEvent, value); }
1623 remove { Events.RemoveHandler (DataMemberChangedEvent, value); }
1626 public event EventHandler DataSourceChanged {
1627 add { Events.AddHandler (DataSourceChangedEvent, value); }
1628 remove { Events.RemoveHandler (DataSourceChangedEvent, value); }
1631 public event EventHandler DefaultCellStyleChanged {
1632 add { Events.AddHandler (DefaultCellStyleChangedEvent, value); }
1633 remove { Events.RemoveHandler (DefaultCellStyleChangedEvent, value); }
1636 [EditorBrowsable (EditorBrowsableState.Advanced)]
1637 public event DataGridViewRowEventHandler DefaultValuesNeeded {
1638 add { Events.AddHandler (DefaultValuesNeededEvent, value); }
1639 remove { Events.RemoveHandler (DefaultValuesNeededEvent, value); }
1642 public event DataGridViewEditingControlShowingEventHandler EditingControlShowing {
1643 add { Events.AddHandler (EditingControlShowingEvent, value); }
1644 remove { Events.RemoveHandler (EditingControlShowingEvent, value); }
1647 public event EventHandler EditModeChanged {
1648 add { Events.AddHandler (EditModeChangedEvent, value); }
1649 remove { Events.RemoveHandler (EditModeChangedEvent, value); }
1653 [EditorBrowsable (EditorBrowsableState.Advanced)]
1654 public new event EventHandler FontChanged {
1655 add { base.FontChanged += value; }
1656 remove { base.FontChanged -= value; }
1660 [EditorBrowsable (EditorBrowsableState.Advanced)]
1661 public new event EventHandler ForeColorChanged {
1662 add { base.ForeColorChanged += value; }
1663 remove { base.ForeColorChanged -= value; }
1667 [EditorBrowsable (EditorBrowsableState.Never)]
1668 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
1669 public new event EventHandler PaddingChanged {
1670 add { base.PaddingChanged += value; }
1671 remove { base.PaddingChanged -= value; }
1674 public event EventHandler GridColorChanged {
1675 add { Events.AddHandler (GridColorChangedEvent, value); }
1676 remove { Events.RemoveHandler (GridColorChangedEvent, value); }
1679 public event EventHandler MultiSelectChanged {
1680 add { Events.AddHandler (MultiSelectChangedEvent, value); }
1681 remove { Events.RemoveHandler (MultiSelectChangedEvent, value); }
1684 public event DataGridViewRowEventHandler NewRowNeeded {
1685 add { Events.AddHandler (NewRowNeededEvent, value); }
1686 remove { Events.RemoveHandler (NewRowNeededEvent, value); }
1689 public event EventHandler ReadOnlyChanged {
1690 add { Events.AddHandler (ReadOnlyChangedEvent, value); }
1691 remove { Events.RemoveHandler (ReadOnlyChangedEvent, value); }
1694 public event DataGridViewRowEventHandler RowContextMenuStripChanged {
1695 add { Events.AddHandler (RowContextMenuStripChangedEvent, value); }
1696 remove { Events.RemoveHandler (RowContextMenuStripChangedEvent, value); }
1699 [EditorBrowsable (EditorBrowsableState.Advanced)]
1700 public event DataGridViewRowContextMenuStripNeededEventHandler RowContextMenuStripNeeded {
1701 add { Events.AddHandler (RowContextMenuStripNeededEvent, value); }
1702 remove { Events.RemoveHandler (RowContextMenuStripNeededEvent, value); }
1705 public event DataGridViewRowEventHandler RowDefaultCellStyleChanged {
1706 add { Events.AddHandler (RowDefaultCellStyleChangedEvent, value); }
1707 remove { Events.RemoveHandler (RowDefaultCellStyleChangedEvent, value); }
1710 [EditorBrowsable (EditorBrowsableState.Advanced)]
1711 public event QuestionEventHandler RowDirtyStateNeeded {
1712 add { Events.AddHandler (RowDirtyStateNeededEvent, value); }
1713 remove { Events.RemoveHandler (RowDirtyStateNeededEvent, value); }
1716 public event DataGridViewRowDividerDoubleClickEventHandler RowDividerDoubleClick {
1717 add { Events.AddHandler (RowDividerDoubleClickEvent, value); }
1718 remove { Events.RemoveHandler (RowDividerDoubleClickEvent, value); }
1721 public event DataGridViewRowEventHandler RowDividerHeightChanged {
1722 add { Events.AddHandler (RowDividerHeightChangedEvent, value); }
1723 remove { Events.RemoveHandler (RowDividerHeightChangedEvent, value); }
1726 public event DataGridViewCellEventHandler RowEnter {
1727 add { Events.AddHandler (RowEnterEvent, value); }
1728 remove { Events.RemoveHandler (RowEnterEvent, value); }
1731 public event DataGridViewRowEventHandler RowErrorTextChanged {
1732 add { Events.AddHandler (RowErrorTextChangedEvent, value); }
1733 remove { Events.RemoveHandler (RowErrorTextChangedEvent, value); }
1736 [EditorBrowsable (EditorBrowsableState.Advanced)]
1737 public event DataGridViewRowErrorTextNeededEventHandler RowErrorTextNeeded {
1738 add { Events.AddHandler (RowErrorTextNeededEvent, value); }
1739 remove { Events.RemoveHandler (RowErrorTextNeededEvent, value); }
1742 public event DataGridViewRowEventHandler RowHeaderCellChanged {
1743 add { Events.AddHandler (RowHeaderCellChangedEvent, value); }
1744 remove { Events.RemoveHandler (RowHeaderCellChangedEvent, value); }
1747 public event DataGridViewCellMouseEventHandler RowHeaderMouseClick {
1748 add { Events.AddHandler (RowHeaderMouseClickEvent, value); }
1749 remove { Events.RemoveHandler (RowHeaderMouseClickEvent, value); }
1752 public event DataGridViewCellMouseEventHandler RowHeaderMouseDoubleClick {
1753 add { Events.AddHandler (RowHeaderMouseDoubleClickEvent, value); }
1754 remove { Events.RemoveHandler (RowHeaderMouseDoubleClickEvent, value); }
1757 public event EventHandler RowHeadersBorderStyleChanged {
1758 add { Events.AddHandler (RowHeadersBorderStyleChangedEvent, value); }
1759 remove { Events.RemoveHandler (RowHeadersBorderStyleChangedEvent, value); }
1762 public event EventHandler RowHeadersDefaultCellStyleChanged {
1763 add { Events.AddHandler (RowHeadersDefaultCellStyleChangedEvent, value); }
1764 remove { Events.RemoveHandler (RowHeadersDefaultCellStyleChangedEvent, value); }
1767 public event EventHandler RowHeadersWidthChanged {
1768 add { Events.AddHandler (RowHeadersWidthChangedEvent, value); }
1769 remove { Events.RemoveHandler (RowHeadersWidthChangedEvent, value); }
1772 public event DataGridViewAutoSizeModeEventHandler RowHeadersWidthSizeModeChanged {
1773 add { Events.AddHandler (RowHeadersWidthSizeModeChangedEvent, value); }
1774 remove { Events.RemoveHandler (RowHeadersWidthSizeModeChangedEvent, value); }
1777 public event DataGridViewRowEventHandler RowHeightChanged {
1778 add { Events.AddHandler (RowHeightChangedEvent, value); }
1779 remove { Events.RemoveHandler (RowHeightChangedEvent, value); }
1782 [EditorBrowsable (EditorBrowsableState.Advanced)]
1783 public event DataGridViewRowHeightInfoNeededEventHandler RowHeightInfoNeeded {
1784 add { Events.AddHandler (RowHeightInfoNeededEvent, value); }
1785 remove { Events.RemoveHandler (RowHeightInfoNeededEvent, value); }
1788 [EditorBrowsable (EditorBrowsableState.Advanced)]
1789 public event DataGridViewRowHeightInfoPushedEventHandler RowHeightInfoPushed {
1790 add { Events.AddHandler (RowHeightInfoPushedEvent, value); }
1791 remove { Events.RemoveHandler (RowHeightInfoPushedEvent, value); }
1794 public event DataGridViewCellEventHandler RowLeave {
1795 add { Events.AddHandler (RowLeaveEvent, value); }
1796 remove { Events.RemoveHandler (RowLeaveEvent, value); }
1799 public event DataGridViewRowEventHandler RowMinimumHeightChanged {
1800 add { Events.AddHandler (RowMinimumHeightChangedEvent, value); }
1801 remove { Events.RemoveHandler (RowMinimumHeightChangedEvent, value); }
1804 public event DataGridViewRowPostPaintEventHandler RowPostPaint {
1805 add { Events.AddHandler (RowPostPaintEvent, value); }
1806 remove { Events.RemoveHandler (RowPostPaintEvent, value); }
1809 public event DataGridViewRowPrePaintEventHandler RowPrePaint {
1810 add { Events.AddHandler (RowPrePaintEvent, value); }
1811 remove { Events.RemoveHandler (RowPrePaintEvent, value); }
1814 public event DataGridViewRowsAddedEventHandler RowsAdded {
1815 add { Events.AddHandler (RowsAddedEvent, value); }
1816 remove { Events.RemoveHandler (RowsAddedEvent, value); }
1819 public event EventHandler RowsDefaultCellStyleChanged {
1820 add { Events.AddHandler (RowsDefaultCellStyleChangedEvent, value); }
1821 remove { Events.RemoveHandler (RowsDefaultCellStyleChangedEvent, value); }
1824 public event DataGridViewRowsRemovedEventHandler RowsRemoved {
1825 add { Events.AddHandler (RowsRemovedEvent, value); }
1826 remove { Events.RemoveHandler (RowsRemovedEvent, value); }
1829 public event DataGridViewRowStateChangedEventHandler RowStateChanged {
1830 add { Events.AddHandler (RowStateChangedEvent, value); }
1831 remove { Events.RemoveHandler (RowStateChangedEvent, value); }
1834 [EditorBrowsable (EditorBrowsableState.Advanced)]
1835 public event DataGridViewRowEventHandler RowUnshared {
1836 add { Events.AddHandler (RowUnsharedEvent, value); }
1837 remove { Events.RemoveHandler (RowUnsharedEvent, value); }
1840 public event DataGridViewCellEventHandler RowValidated {
1841 add { Events.AddHandler (RowValidatedEvent, value); }
1842 remove { Events.RemoveHandler (RowValidatedEvent, value); }
1845 public event DataGridViewCellCancelEventHandler RowValidating {
1846 add { Events.AddHandler (RowValidatingEvent, value); }
1847 remove { Events.RemoveHandler (RowValidatingEvent, value); }
1850 public event ScrollEventHandler Scroll {
1851 add { Events.AddHandler (ScrollEvent, value); }
1852 remove { Events.RemoveHandler (ScrollEvent, value); }
1855 public event EventHandler SelectionChanged {
1856 add { Events.AddHandler (SelectionChangedEvent, value); }
1857 remove { Events.RemoveHandler (SelectionChangedEvent, value); }
1860 [EditorBrowsable (EditorBrowsableState.Advanced)]
1861 public event DataGridViewSortCompareEventHandler SortCompare {
1862 add { Events.AddHandler (SortCompareEvent, value); }
1863 remove { Events.RemoveHandler (SortCompareEvent, value); }
1866 public event EventHandler Sorted {
1867 add { Events.AddHandler (SortedEvent, value); }
1868 remove { Events.RemoveHandler (SortedEvent, value); }
1871 public event DataGridViewRowEventHandler UserAddedRow {
1872 add { Events.AddHandler (UserAddedRowEvent, value); }
1873 remove { Events.RemoveHandler (UserAddedRowEvent, value); }
1876 public event DataGridViewRowEventHandler UserDeletedRow {
1877 add { Events.AddHandler (UserDeletedRowEvent, value); }
1878 remove { Events.RemoveHandler (UserDeletedRowEvent, value); }
1881 public event DataGridViewRowCancelEventHandler UserDeletingRow {
1882 add { Events.AddHandler (UserDeletingRowEvent, value); }
1883 remove { Events.RemoveHandler (UserDeletingRowEvent, value); }
1887 [EditorBrowsable (EditorBrowsableState.Never)]
1888 public new event EventHandler StyleChanged {
1889 add { base.StyleChanged += value; }
1890 remove { base.StyleChanged -= value; }
1894 [EditorBrowsable (EditorBrowsableState.Never)]
1895 public new event EventHandler TextChanged {
1896 add { base.TextChanged += value; }
1897 remove { base.TextChanged -= value; }
1900 [EditorBrowsable (EditorBrowsableState.Advanced)]
1901 public virtual DataGridViewAdvancedBorderStyle AdjustColumnHeaderBorderStyle (DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStyleInput, DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder, bool isFirstDisplayedColumn, bool isLastVisibleColumn) {
1902 return (DataGridViewAdvancedBorderStyle) ((ICloneable)dataGridViewAdvancedBorderStyleInput).Clone();
1905 public bool AreAllCellsSelected (bool includeInvisibleCells) {
1906 foreach (DataGridViewRow row in rows) {
1907 foreach (DataGridViewCell cell in row.Cells) {
1908 if (includeInvisibleCells == false && cell.Visible == false) {
1911 if (!cell.Selected) {
1919 public void AutoResizeColumn (int columnIndex) {
1920 throw new NotImplementedException();
1923 public void AutoResizeColumn (int columnIndex, DataGridViewAutoSizeColumnMode autoSizeColumnMode) {
1924 throw new NotImplementedException();
1927 public void AutoResizeColumnHeadersHeight () {
1928 throw new NotImplementedException();
1931 public void AutoResizeColumnHeadersHeight (int columnIndex) {
1932 throw new NotImplementedException();
1935 public void AutoResizeColumns () {
1936 throw new NotImplementedException();
1939 public void AutoResizeColumns (DataGridViewAutoSizeColumnsMode autoSizeColumnsMode) {
1940 throw new NotImplementedException();
1943 public void AutoResizeRow (int rowIndex) {
1944 throw new NotImplementedException();
1947 public void AutoResizeRow (int rowIndex, DataGridViewAutoSizeRowMode autoSizeRowMode) {
1948 throw new NotImplementedException();
1951 public void AutoResizeRowHeadersWidth (DataGridViewRowHeadersWidthSizeMode rowHeadersWidthSizeMode) {
1952 throw new NotImplementedException();
1955 public void AutoResizeRowHeadersWidth (int rowIndex, DataGridViewRowHeadersWidthSizeMode rowHeadersWidthSizeMode) {
1956 throw new NotImplementedException();
1959 public void AutoResizeRows () {
1960 throw new NotImplementedException();
1963 public void AutoResizeRows (DataGridViewAutoSizeRowsMode autoSizeRowsMode) {
1964 if (!Enum.IsDefined(typeof(DataGridViewAutoSizeRowsMode), autoSizeRowsMode)) {
1965 throw new InvalidEnumArgumentException("Parameter AutoSizeRowsMode is not valid DataGridViewRowsMode.");
1967 if ((autoSizeRowsMode == DataGridViewAutoSizeRowsMode.AllHeaders || autoSizeRowsMode == DataGridViewAutoSizeRowsMode.DisplayedHeaders) && rowHeadersVisible == false) {
1968 throw new InvalidOperationException("Parameter AutoSizeRowsMode cant be AllHeaders or DisplayedHeaders in this DataGridView.");
1970 if (autoSizeRowsMode == DataGridViewAutoSizeRowsMode.None) {
1971 throw new ArgumentException("Parameter AutoSieRowsMode cant be None.");
1975 public virtual bool BeginEdit (bool selectAll) {
1976 throw new NotImplementedException();
1979 public bool CancelEdit () {
1980 throw new NotImplementedException();
1983 public void ClearSelection () {
1984 foreach (DataGridViewCell cell in SelectedCells) {
1985 cell.Selected = false;
1989 public bool CommitEdit (DataGridViewDataErrorContexts context) {
1990 throw new NotImplementedException();
1993 public int DisplayedColumnCount (bool includePartialColumns) {
1994 /////////////////////// PartialColumns?
1996 foreach (DataGridViewColumn col in columns) {
2004 public int DisplayedRowCount (bool includePartialRow) {
2005 /////////////////////// PartialRows?
2007 foreach (DataGridViewRow row in rows) {
2015 public bool EndEdit () {
2016 throw new NotImplementedException();
2019 public bool EndEdit (DataGridViewDataErrorContexts context) {
2020 throw new NotImplementedException();
2023 public int GetCellCount (DataGridViewElementStates includeFilter) {
2025 foreach (DataGridViewRow row in rows) {
2026 foreach (DataGridViewCell cell in row.Cells) {
2027 if ((cell.State & includeFilter) != 0) {
2035 public Rectangle GetCellDisplayRectangle (int columnIndex, int rowIndex, bool cutOverflow) {
2036 if (columnIndex < 0 || columnIndex >= columns.Count) {
2037 throw new ArgumentOutOfRangeException("Column index is out of range.");
2039 throw new NotImplementedException();
2042 public virtual DataObject GetClipboardContent () {
2043 throw new NotImplementedException();
2046 public Rectangle GetColumnDisplayRectangle (int columnIndex, bool cutOverflow) {
2047 throw new NotImplementedException();
2050 public Rectangle GetRowDisplayRectangle (int rowIndex, bool cutOverflow) {
2051 throw new NotImplementedException();
2054 public HitTestInfo HitTest (int x, int y) {
2055 ///////////////////////////////////////////////////////
2056 x += horizontalScrollingOffset;
2057 y += verticalScrollingOffset;
2059 int totalHeight = (columnHeadersVisible)? 1 + columnHeadersHeight : 1;
2060 if (columnHeadersVisible && y <= totalHeight) {
2064 foreach (DataGridViewRow row in rows.RowIndexSortedArrayList) {
2065 totalHeight += row.Height;
2066 if (y <= totalHeight) {
2067 rowIndex = row.Index;
2070 totalHeight++; // sumar el ancho de las lineas...
2074 int totalWidth = (rowHeadersVisible)? 1 + rowHeadersWidth : 1;
2075 if (rowHeadersVisible && x <= totalWidth) {
2079 foreach (DataGridViewColumn col in columns.ColumnDisplayIndexSortedArrayList) {
2080 totalWidth += col.Width;
2081 if (x <= totalWidth) {
2082 colIndex = col.Index;
2088 HitTestInfo result = new HitTestInfo(colIndex, x, rowIndex, y, (colIndex >= 0 && rowIndex >= 0)? DataGridViewHitTestType.Cell : DataGridViewHitTestType.None);
2092 public void InvalidateCell (DataGridViewCell dataGridViewCell) {
2093 if (dataGridViewCell == null) {
2094 throw new ArgumentNullException("Cell is null");
2096 if (dataGridViewCell.DataGridView != this) {
2097 throw new ArgumentException("The specified cell does not belong to this DataGridView.");
2099 throw new NotImplementedException();
2102 public void InvalidateCell (int columnIndex, int rowIndex) {
2103 if (columnIndex < 0 || columnIndex >= columns.Count) {
2104 throw new ArgumentOutOfRangeException("Column index is out of range.");
2106 if (rowIndex < 0 || rowIndex >= rows.Count) {
2107 throw new ArgumentOutOfRangeException("Row index is out of range.");
2109 foreach (DataGridViewRow row in rows) {
2110 foreach (DataGridViewCell cell in row.Cells) {
2111 if (cell.RowIndex == rowIndex && cell.ColumnIndex == columnIndex) {
2112 InvalidateCell(cell); //// O al revés, que el otro llame a este !!!
2119 public void InvalidateColumn (int columnIndex) {
2120 if (columnIndex < 0 || columnIndex >= columns.Count) {
2121 throw new ArgumentOutOfRangeException("Column index is out of range.");
2123 throw new NotImplementedException();
2126 public void InvalidateRow (int rowIndex) {
2127 if (rowIndex < 0 || rowIndex >= rows.Count) {
2128 throw new ArgumentOutOfRangeException("Row index is out of range.");
2130 throw new NotImplementedException();
2133 public virtual void NotifyCurrentCellDirty (bool dirty) {
2134 throw new NotImplementedException();
2137 public bool RefreshEdit () {
2138 throw new NotImplementedException();
2141 [EditorBrowsable (EditorBrowsableState.Never)]
2142 public override void ResetText () {
2143 throw new NotImplementedException();
2146 public void SelectAll () {
2147 switch (selectionMode) {
2148 case DataGridViewSelectionMode.FullRowSelect:
2149 foreach (DataGridViewRow row in rows) {
2150 (row as DataGridViewBand).Selected = true;
2153 case DataGridViewSelectionMode.FullColumnSelect:
2154 foreach (DataGridViewColumn col in columns) {
2155 (col as DataGridViewBand).Selected = true;
2159 foreach (DataGridViewRow row in rows) {
2160 foreach (DataGridViewCell cell in row.Cells) {
2161 cell.Selected = true;
2168 public virtual void Sort (IComparer comparer) {
2169 throw new NotImplementedException();
2172 public virtual void Sort (DataGridViewColumn dataGridViewColumn, ListSortDirection direction) {
2173 throw new NotImplementedException();
2176 public void UpdateCellErrorText (int columnIndex, int rowIndex)
2178 throw new NotImplementedException();
2181 public void UpdateCellValue (int columnIndex, int rowIndex)
2183 throw new NotImplementedException();
2186 public void UpdateRowErrorText (int rowIndex)
2188 throw new NotImplementedException();
2191 public void UpdateRowErrorText (int rowIndexStart, int rowIndexEnd) {
2192 throw new NotImplementedException();
2195 public void UpdateRowHeightInfo (int rowIndex, bool updateToEnd) {
2196 throw new NotImplementedException();
2199 protected override Size DefaultSize {
2200 get { return new Size (240, 150); }
2203 protected ScrollBar HorizontalScrollBar {
2204 get { return horizontalScrollBar; }
2207 protected ScrollBar VerticalScrollBar {
2208 get { return verticalScrollBar; }
2211 protected virtual void AccessibilityNotifyCurrentCellChanged (Point cellAddress)
2213 throw new NotImplementedException ();
2216 protected void AutoResizeColumn (int columnIndex, DataGridViewAutoSizeColumnMode autoSizeColumnMode, bool fixedHeight) {
2217 throw new NotImplementedException();
2220 protected void AutoResizeColumnHeadersHeight (bool fixedRowHeadersWidth, bool fixedColumnsWidth) {
2221 throw new NotImplementedException();
2224 protected void AutoResizeColumnHeadersHeight (int columnIndex, bool fixedRowHeadersWidth, bool fixedColumnWidth) {
2225 throw new NotImplementedException();
2228 protected void AutoResizeColumns (DataGridViewAutoSizeColumnsMode autoSizeColumnsMode, bool fixedHeight) {
2229 throw new NotImplementedException();
2232 protected void AutoResizeRow (int rowIndex, DataGridViewAutoSizeRowMode autoSizeRowMode, bool fixedWidth) {
2233 throw new NotImplementedException();
2236 protected void AutoResizeRowHeadersWidth (DataGridViewRowHeadersWidthSizeMode rowHeadersWidthSizeMode, bool fixedColumnHeadersHeight, bool fixedRowsHeight) {
2237 throw new NotImplementedException();
2240 protected void AutoResizeRowHeadersWidth (int rowIndex, DataGridViewRowHeadersWidthSizeMode rowHeadersWidthSizeMode, bool fixedColumnHeadersHeight, bool fixedRowHeight) {
2241 throw new NotImplementedException();
2244 protected void AutoResizeRows (DataGridViewAutoSizeRowsMode autoSizeRowsMode, bool fixedWidth) {
2245 throw new NotImplementedException();
2248 protected void AutoResizeRows (int rowIndexStart, int rowsCount, DataGridViewAutoSizeRowMode autoSizeRowMode, bool fixedWidth) {
2249 throw new NotImplementedException();
2252 protected void ClearSelection (int columnIndexException, int rowIndexException, bool selectExceptionElement) {
2253 if (columnIndexException >= columns.Count) {
2254 throw new ArgumentOutOfRangeException("ColumnIndexException is greater than the highest column index.");
2256 if (selectionMode == DataGridViewSelectionMode.FullRowSelect) {
2257 if (columnIndexException < -1) {
2258 throw new ArgumentOutOfRangeException("ColumnIndexException is less than -1.");
2262 if (columnIndexException < 0) {
2263 throw new ArgumentOutOfRangeException("ColumnIndexException is less than 0.");
2266 if (rowIndexException >= rows.Count) {
2267 throw new ArgumentOutOfRangeException("RowIndexException is greater than the highest row index.");
2269 if (selectionMode == DataGridViewSelectionMode.FullColumnSelect) {
2270 if (rowIndexException < -1) {
2271 throw new ArgumentOutOfRangeException("RowIndexException is less than -1.");
2275 if (rowIndexException < 0) {
2276 throw new ArgumentOutOfRangeException("RowIndexException is less than 0.");
2279 switch (selectionMode) {
2280 case DataGridViewSelectionMode.FullRowSelect:
2281 foreach (DataGridViewRow row in rows) {
2282 if (selectExceptionElement && row.Index == rowIndexException) {
2285 row.Selected = false;
2288 case DataGridViewSelectionMode.FullColumnSelect:
2289 foreach (DataGridViewColumn col in columns) {
2290 if (selectExceptionElement && col.Index == columnIndexException) {
2293 col.Selected = false;
2297 foreach (DataGridViewCell cell in SelectedCells) {
2298 if (selectExceptionElement && cell.RowIndex == rowIndexException && cell.ColumnIndex == columnIndexException) {
2301 cell.Selected = false;
2307 protected override AccessibleObject CreateAccessibilityInstance ()
2309 return new DataGridViewAccessibleObject(this);
2312 [EditorBrowsable (EditorBrowsableState.Advanced)]
2313 protected virtual DataGridViewColumnCollection CreateColumnsInstance ()
2315 return new DataGridViewColumnCollection(this);
2318 protected override Control.ControlCollection CreateControlsInstance ()
2320 return base.CreateControlsInstance(); //new Control.ControlCollection(this);
2323 [EditorBrowsable (EditorBrowsableState.Advanced)]
2324 protected virtual DataGridViewRowCollection CreateRowsInstance ()
2326 return new DataGridViewRowCollection(this);
2329 protected override void Dispose (bool disposing) {
2332 protected override AccessibleObject GetAccessibilityObjectById (int objectId)
2334 throw new NotImplementedException();
2337 protected override bool IsInputChar (char charCode)
2339 return base.IsInputChar(charCode);
2342 protected override bool IsInputKey (Keys keyData)
2344 return base.IsInputKey(keyData);
2347 protected virtual void OnAllowUserToAddRowsChanged (EventArgs e)
2349 EventHandler eh = (EventHandler)(Events [AllowUserToAddRowsChangedEvent]);
2354 protected virtual void OnAllowUserToDeleteRowsChanged (EventArgs e)
2356 EventHandler eh = (EventHandler)(Events [AllowUserToDeleteRowsChangedEvent]);
2361 protected virtual void OnAllowUserToOrderColumnsChanged (EventArgs e)
2363 EventHandler eh = (EventHandler)(Events [AllowUserToOrderColumnsChangedEvent]);
2368 protected virtual void OnAllowUserToResizeColumnsChanged (EventArgs e)
2370 EventHandler eh = (EventHandler)(Events [AllowUserToResizeColumnsChangedEvent]);
2375 protected virtual void OnAllowUserToResizeRowsChanged (EventArgs e)
2377 EventHandler eh = (EventHandler)(Events [AllowUserToResizeRowsChangedEvent]);
2382 protected virtual void OnAlternatingRowsDefaultCellStyleChanged (EventArgs e)
2384 EventHandler eh = (EventHandler)(Events [AlternatingRowsDefaultCellStyleChangedEvent]);
2389 protected virtual void OnAutoGenerateColumnsChanged (EventArgs e)
2391 EventHandler eh = (EventHandler)(Events [AutoGenerateColumnsChangedEvent]);
2396 protected virtual void OnAutoSizeColumnModeChanged (DataGridViewAutoSizeColumnModeEventArgs e)
2398 DataGridViewAutoSizeColumnModeEventHandler eh = (DataGridViewAutoSizeColumnModeEventHandler)(Events [AutoSizeColumnModeChangedEvent]);
2403 protected virtual void OnAutoSizeColumnsModeChanged (DataGridViewAutoSizeColumnsModeEventArgs e)
2405 DataGridViewAutoSizeColumnsModeEventHandler eh = (DataGridViewAutoSizeColumnsModeEventHandler)(Events [AutoSizeColumnsModeChangedEvent]);
2410 protected virtual void OnAutoSizeRowsModeChanged (DataGridViewAutoSizeModeEventArgs e)
2412 DataGridViewAutoSizeModeEventHandler eh = (DataGridViewAutoSizeModeEventHandler)(Events [AutoSizeRowsModeChangedEvent]);
2417 protected virtual void OnBackgroundColorChanged (EventArgs e)
2419 EventHandler eh = (EventHandler)(Events [BackgroundColorChangedEvent]);
2424 protected override void OnBindingContextChanged (EventArgs e)
2426 base.OnBindingContextChanged(e);
2429 protected virtual void OnBorderStyleChanged (EventArgs e)
2431 EventHandler eh = (EventHandler)(Events [BorderStyleChangedEvent]);
2436 protected virtual void OnCancelRowEdit (QuestionEventArgs e) {
2437 QuestionEventHandler eh = (QuestionEventHandler)(Events [CancelRowEditEvent]);
2442 protected virtual void OnCellBeginEdit (DataGridViewCellCancelEventArgs e)
2444 DataGridViewCellCancelEventHandler eh = (DataGridViewCellCancelEventHandler)(Events [CellBeginEditEvent]);
2449 protected virtual void OnCellBorderStyleChanged (EventArgs e)
2451 EventHandler eh = (EventHandler)(Events [CellBorderStyleChangedEvent]);
2456 protected virtual void OnCellClick (DataGridViewCellEventArgs e)
2458 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellClickEvent]);
2463 protected virtual void OnCellContentClick (DataGridViewCellEventArgs e)
2465 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellContentClickEvent]);
2470 protected virtual void OnCellContentDoubleClick (DataGridViewCellEventArgs e)
2472 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellContentDoubleClickEvent]);
2477 protected virtual void OnCellContextMenuStripChanged (DataGridViewCellEventArgs e)
2479 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellContextMenuStripChangedEvent]);
2484 protected virtual void OnCellContextMenuStripNeeded (DataGridViewCellContextMenuStripNeededEventArgs e)
2486 DataGridViewCellContextMenuStripNeededEventHandler eh = (DataGridViewCellContextMenuStripNeededEventHandler)(Events [CellContextMenuStripNeededEvent]);
2491 protected virtual void OnCellDoubleClick (DataGridViewCellEventArgs e)
2493 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellDoubleClickEvent]);
2498 protected virtual void OnCellEndEdit (DataGridViewCellEventArgs e)
2500 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellEndEditEvent]);
2505 protected virtual void OnCellEnter (DataGridViewCellEventArgs e)
2507 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellEnterEvent]);
2512 protected internal virtual void OnCellErrorTextChanged (DataGridViewCellEventArgs e)
2514 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellErrorTextChangedEvent]);
2519 protected virtual void OnCellErrorTextNeeded (DataGridViewCellErrorTextNeededEventArgs e)
2521 DataGridViewCellErrorTextNeededEventHandler eh = (DataGridViewCellErrorTextNeededEventHandler)(Events [CellErrorTextNeededEvent]);
2526 protected virtual void OnCellFormatting (DataGridViewCellFormattingEventArgs e)
2528 DataGridViewCellFormattingEventHandler eh = (DataGridViewCellFormattingEventHandler)(Events [CellFormattingEvent]);
2533 protected virtual void OnCellLeave (DataGridViewCellEventArgs e)
2535 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellLeaveEvent]);
2540 protected virtual void OnCellMouseClick (DataGridViewCellMouseEventArgs e)
2542 DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [CellMouseClickEvent]);
2547 protected virtual void OnCellMouseDoubleClick (DataGridViewCellMouseEventArgs e)
2549 DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [CellMouseDoubleClickEvent]);
2554 protected virtual void OnCellMouseDown (DataGridViewCellMouseEventArgs e)
2556 DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [CellMouseDownEvent]);
2561 protected virtual void OnCellMouseEnter (DataGridViewCellEventArgs e)
2563 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellMouseEnterEvent]);
2568 protected virtual void OnCellMouseLeave (DataGridViewCellEventArgs e)
2570 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellMouseLeaveEvent]);
2575 protected virtual void OnCellMouseMove (DataGridViewCellMouseEventArgs e)
2577 DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [CellMouseMoveEvent]);
2582 protected virtual void OnCellMouseUp (DataGridViewCellMouseEventArgs e)
2584 DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [CellMouseUpEvent]);
2589 protected virtual void OnCellPainting (DataGridViewCellPaintingEventArgs e)
2591 DataGridViewCellPaintingEventHandler eh = (DataGridViewCellPaintingEventHandler)(Events [CellPaintingEvent]);
2596 protected internal virtual void OnCellParsing (DataGridViewCellParsingEventArgs e)
2598 DataGridViewCellParsingEventHandler eh = (DataGridViewCellParsingEventHandler)(Events [CellParsingEvent]);
2603 protected virtual void OnCellStateChanged (DataGridViewCellStateChangedEventArgs e)
2605 DataGridViewCellStateChangedEventHandler eh = (DataGridViewCellStateChangedEventHandler)(Events [CellStateChangedEvent]);
2610 protected virtual void OnCellStyleChanged (DataGridViewCellEventArgs e)
2612 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellStyleChangedEvent]);
2617 protected virtual void OnCellStyleContentChanged (DataGridViewCellStyleContentChangedEventArgs e) {
2618 DataGridViewCellStyleContentChangedEventHandler eh = (DataGridViewCellStyleContentChangedEventHandler)(Events [CellStyleContentChangedEvent]);
2623 protected virtual void OnCellToolTipTextChanged (DataGridViewCellEventArgs e) {
2624 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellToolTipTextChangedEvent]);
2629 protected virtual void OnCellToolTipTextNeeded (DataGridViewCellToolTipTextNeededEventArgs e)
2631 DataGridViewCellToolTipTextNeededEventHandler eh = (DataGridViewCellToolTipTextNeededEventHandler)(Events [CellToolTipTextNeededEvent]);
2636 protected virtual void OnCellValidated (DataGridViewCellEventArgs e)
2638 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellValidatedEvent]);
2643 protected virtual void OnCellValidating (DataGridViewCellValidatingEventArgs e)
2645 DataGridViewCellValidatingEventHandler eh = (DataGridViewCellValidatingEventHandler)(Events [CellValidatingEvent]);
2650 protected virtual void OnCellValueChanged (DataGridViewCellEventArgs e)
2652 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellValueChangedEvent]);
2657 protected virtual void OnCellValueNeeded (DataGridViewCellValueEventArgs e)
2659 DataGridViewCellValueEventHandler eh = (DataGridViewCellValueEventHandler)(Events [CellValueNeededEvent]);
2664 protected virtual void OnCellValuePushed (DataGridViewCellValueEventArgs e)
2666 DataGridViewCellValueEventHandler eh = (DataGridViewCellValueEventHandler)(Events [CellValuePushedEvent]);
2671 protected virtual void OnColumnAdded (DataGridViewColumnEventArgs e)
2673 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnAddedEvent]);
2678 protected internal virtual void OnColumnContextMenuStripChanged (DataGridViewColumnEventArgs e)
2680 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnContextMenuStripChangedEvent]);
2685 protected internal virtual void OnColumnDataPropertyNameChanged (DataGridViewColumnEventArgs e)
2687 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnDataPropertyNameChangedEvent]);
2692 protected internal virtual void OnColumnDefaultCellStyleChanged (DataGridViewColumnEventArgs e)
2694 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnDefaultCellStyleChangedEvent]);
2699 protected internal virtual void OnColumnDisplayIndexChanged (DataGridViewColumnEventArgs e)
2701 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnDisplayIndexChangedEvent]);
2706 protected virtual void OnColumnDividerDoubleClick (DataGridViewColumnDividerDoubleClickEventArgs e)
2708 DataGridViewColumnDividerDoubleClickEventHandler eh = (DataGridViewColumnDividerDoubleClickEventHandler)(Events [ColumnDividerDoubleClickEvent]);
2713 protected internal virtual void OnColumnDividerWidthChanged (DataGridViewColumnEventArgs e)
2715 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnDividerWidthChangedEvent]);
2720 protected internal virtual void OnColumnHeaderCellChanged (DataGridViewColumnEventArgs e)
2722 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnHeaderCellChangedEvent]);
2727 protected virtual void OnColumnHeaderMouseClick (DataGridViewCellMouseEventArgs e)
2729 DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [ColumnHeaderMouseClickEvent]);
2734 protected virtual void OnColumnHeaderMouseDoubleClick (DataGridViewCellMouseEventArgs e)
2736 DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [ColumnHeaderMouseDoubleClickEvent]);
2741 protected virtual void OnColumnHeadersBorderStyleChanged (EventArgs e)
2743 EventHandler eh = (EventHandler)(Events [ColumnHeadersBorderStyleChangedEvent]);
2748 protected virtual void OnColumnHeadersDefaultCellStyleChanged (EventArgs e)
2750 EventHandler eh = (EventHandler)(Events [ColumnHeadersDefaultCellStyleChangedEvent]);
2755 protected virtual void OnColumnHeadersHeightChanged (EventArgs e)
2757 EventHandler eh = (EventHandler)(Events [ColumnHeadersHeightChangedEvent]);
2762 protected virtual void OnColumnHeadersHeightSizeModeChanged (DataGridViewAutoSizeModeEventArgs e)
2764 DataGridViewAutoSizeModeEventHandler eh = (DataGridViewAutoSizeModeEventHandler)(Events [ColumnHeadersHeightSizeModeChangedEvent]);
2769 protected internal virtual void OnColumnMinimumWidthChanged (DataGridViewColumnEventArgs e)
2771 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnMinimumWidthChangedEvent]);
2776 protected internal virtual void OnColumnNameChanged (DataGridViewColumnEventArgs e)
2778 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnNameChangedEvent]);
2783 protected virtual void OnColumnRemoved (DataGridViewColumnEventArgs e)
2785 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnRemovedEvent]);
2790 protected internal virtual void OnColumnSortModeChanged (DataGridViewColumnEventArgs e)
2792 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnSortModeChangedEvent]);
2797 protected internal virtual void OnColumnStateChanged (DataGridViewColumnStateChangedEventArgs e)
2799 DataGridViewColumnStateChangedEventHandler eh = (DataGridViewColumnStateChangedEventHandler)(Events [ColumnStateChangedEvent]);
2804 protected internal virtual void OnColumnToolTipTextChanged (DataGridViewColumnEventArgs e)
2806 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnToolTipTextChangedEvent]);
2811 protected internal virtual void OnColumnWidthChanged (DataGridViewColumnEventArgs e)
2813 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnWidthChangedEvent]);
2818 protected virtual void OnCurrentCellChanged (EventArgs e)
2820 EventHandler eh = (EventHandler)(Events [CurrentCellChangedEvent]);
2825 protected virtual void OnCurrentCellDirtyStateChanged (EventArgs e)
2827 EventHandler eh = (EventHandler)(Events [CurrentCellDirtyStateChangedEvent]);
2832 protected override void OnCursorChanged (EventArgs e)
2834 base.OnCursorChanged (e);
2837 protected virtual void OnDataBindingComplete (DataGridViewBindingCompleteEventArgs e)
2839 DataGridViewBindingCompleteEventHandler eh = (DataGridViewBindingCompleteEventHandler)(Events [DataBindingCompleteEvent]);
2844 protected virtual void OnDataError (bool displayErrorDialogIfNoHandler, DataGridViewDataErrorEventArgs e) {
2845 DataGridViewDataErrorEventHandler eh = (DataGridViewDataErrorEventHandler)(Events [DataErrorEvent]);
2850 if (displayErrorDialogIfNoHandler) {
2851 /////////////////////////////////// ERROR DIALOG //////////////////////////////////7
2855 protected virtual void OnDataMemberChanged (EventArgs e) {
2856 EventHandler eh = (EventHandler)(Events [DataMemberChangedEvent]);
2861 protected virtual void OnDataSourceChanged (EventArgs e) {
2862 EventHandler eh = (EventHandler)(Events [DataSourceChangedEvent]);
2867 protected virtual void OnDefaultCellStyleChanged (EventArgs e) {
2868 EventHandler eh = (EventHandler)(Events [DefaultCellStyleChangedEvent]);
2873 protected virtual void OnDefaultValuesNeeded (DataGridViewRowEventArgs e) {
2874 DataGridViewRowEventHandler eh = (DataGridViewRowEventHandler)(Events [DefaultValuesNeededEvent]);
2879 protected override void OnDoubleClick (EventArgs e) {
2880 base.OnDoubleClick(e);
2883 protected virtual void OnEditingControlShowing (DataGridViewEditingControlShowingEventArgs e) {
2884 DataGridViewEditingControlShowingEventHandler eh = (DataGridViewEditingControlShowingEventHandler)(Events [EditingControlShowingEvent]);
2889 protected virtual void OnEditModeChanged (EventArgs e)
2891 EventHandler eh = (EventHandler)(Events [EditModeChangedEvent]);
2896 protected override void OnEnabledChanged (EventArgs e)
2898 base.OnEnabledChanged(e);
2901 protected override void OnEnter (EventArgs e )
2906 protected override void OnGotFocus(EventArgs e)
2908 base.OnGotFocus (e);
2911 protected override void OnFontChanged (EventArgs e)
2913 base.OnFontChanged(e);
2916 protected override void OnForeColorChanged (EventArgs e)
2918 base.OnForeColorChanged(e);
2921 protected virtual void OnGridColorChanged (EventArgs e)
2923 EventHandler eh = (EventHandler)(Events [GridColorChangedEvent]);
2928 protected override void OnHandleCreated (EventArgs e)
2930 base.OnHandleCreated(e);
2933 protected override void OnHandleDestroyed(EventArgs e)
2935 base.OnHandleDestroyed (e);
2938 [EditorBrowsable (EditorBrowsableState.Advanced)]
2939 protected override void OnKeyDown (KeyEventArgs e)
2944 [EditorBrowsable (EditorBrowsableState.Advanced)]
2945 protected override void OnKeyPress (KeyPressEventArgs e)
2950 [EditorBrowsable (EditorBrowsableState.Advanced)]
2951 protected override void OnKeyUp (KeyEventArgs e)
2956 protected override void OnLayout (LayoutEventArgs e)
2961 protected override void OnLeave (EventArgs e)
2966 protected override void OnLostFocus(EventArgs e)
2968 base.OnLostFocus (e);
2971 protected override void OnMouseClick (MouseEventArgs e)
2973 base.OnMouseClick(e);
2974 //Console.WriteLine("Mouse: Clicks: {0}; Delta: {1}; X: {2}; Y: {3};", e.Clicks, e.Delta, e.X, e.Y);
2977 protected override void OnMouseDoubleClick (MouseEventArgs e)
2979 base.OnMouseDoubleClick(e);
2982 protected override void OnMouseDown (MouseEventArgs e)
2984 base.OnMouseDown(e);
2985 //Console.WriteLine("Mouse: Clicks: {0}; Delta: {1}; X: {2}; Y: {3};", e.Clicks, e.Delta, e.X, e.Y);
2986 HitTestInfo hitTest = HitTest(e.X, e.Y);
2987 //Console.WriteLine("HitTest: Column: {0}; Row: {1};", hitTest.ColumnIndex, hitTest.RowIndex);
2988 if (hitTest.RowIndex < 0 || hitTest.ColumnIndex < 0) {
2991 OnCellClick(new DataGridViewCellEventArgs(hitTest.ColumnIndex, hitTest.RowIndex));
2992 DataGridViewRow row = rows[hitTest.RowIndex];
2993 DataGridViewCell cell = row.Cells[hitTest.ColumnIndex];
2994 ClearSelection(0, 0, false);
2995 switch (selectionMode) {
2996 case DataGridViewSelectionMode.FullRowSelect:
2997 row.Selected = true;
2999 case DataGridViewSelectionMode.FullColumnSelect:
3003 cell.Selected = true;
3006 if (cell == currentCell) {
3007 currentCell.SetIsInEditMode(true);
3008 OnCellBeginEdit(new DataGridViewCellCancelEventArgs(currentCell.ColumnIndex, currentCell.RowIndex));
3012 if (currentCell != null) {
3013 if (currentCell.IsInEditMode) {
3014 currentCell.SetIsInEditMode(false);
3015 currentCell.DetachEditingControl();
3016 OnCellEndEdit(new DataGridViewCellEventArgs(currentCell.ColumnIndex, currentCell.RowIndex));
3018 OnCellLeave(new DataGridViewCellEventArgs(currentCell.ColumnIndex, currentCell.RowIndex));
3021 OnCurrentCellChanged(EventArgs.Empty);
3022 OnCellEnter(new DataGridViewCellEventArgs(cell.ColumnIndex, cell.RowIndex));
3023 if (editMode == DataGridViewEditMode.EditOnEnter) {
3024 currentCell.SetIsInEditMode(true);
3025 OnCellBeginEdit(new DataGridViewCellCancelEventArgs(currentCell.ColumnIndex, currentCell.RowIndex));
3031 protected override void OnMouseEnter (EventArgs e)
3033 base.OnMouseEnter(e);
3036 protected override void OnMouseLeave (EventArgs e)
3038 base.OnMouseLeave(e);
3041 protected override void OnMouseMove (MouseEventArgs e)
3043 base.OnMouseMove(e);
3046 protected override void OnMouseUp (MouseEventArgs e)
3051 protected override void OnMouseWheel (MouseEventArgs e)
3053 base.OnMouseWheel(e);
3056 protected virtual void OnMultiSelectChanged (EventArgs e)
3058 EventHandler eh = (EventHandler)(Events [MultiSelectChangedEvent]);
3059 if (eh != null) eh (this, e);
3062 protected virtual void OnNewRowNeeded (DataGridViewRowEventArgs e) {
3063 DataGridViewRowEventHandler eh = (DataGridViewRowEventHandler)(Events [NewRowNeededEvent]);
3064 if (eh != null) eh (this, e);
3067 protected override void OnPaint (PaintEventArgs e) {
3069 //Console.WriteLine(e.ClipRectangle);
3070 Rectangle bounds = ClientRectangle; //e.ClipRectangle;
3071 e.Graphics.FillRectangle(new SolidBrush(backgroundColor), bounds);
3072 Pen pen = new Pen(gridColor);
3075 ArrayList sortedColumns = columns.ColumnDisplayIndexSortedArrayList;
3076 bounds.Y = -verticalScrollingOffset;
3077 bounds.X = -horizontalScrollingOffset;
3079 foreach (DataGridViewColumn col in sortedColumns) {
3080 gridWidth += col.Width;
3082 if (columnHeadersVisible) {
3083 Rectangle headerBounds = bounds;
3084 if (rowHeadersVisible) {
3085 headerBounds.X += rowHeadersWidth;
3087 headerBounds.Height = columnHeadersHeight;
3089 foreach (DataGridViewColumn col in sortedColumns) {
3090 headerBounds.Width = col.Width;
3091 DataGridViewCell cell = col.HeaderCell;
3092 DataGridViewCellStyle style = columnHeadersDefaultCellStyle;
3093 DataGridViewAdvancedBorderStyle intermediateBorderStyle = (DataGridViewAdvancedBorderStyle) ((ICloneable)this.AdvancedColumnHeadersBorderStyle).Clone();
3094 DataGridViewAdvancedBorderStyle borderStyle = AdjustColumnHeaderBorderStyle(this.AdvancedColumnHeadersBorderStyle, intermediateBorderStyle, j == 0, j == columns.Count - 1);
3095 cell.InternalPaint(e.Graphics, e.ClipRectangle, headerBounds, cell.RowIndex, cell.State, cell.Value, cell.FormattedValue, cell.ErrorText, style, borderStyle, DataGridViewPaintParts.All);
3096 headerBounds.X += col.Width;
3099 bounds.Y += columnHeadersHeight;
3102 foreach (DataGridViewRow row in rows) {
3103 gridHeight += row.Height;
3104 if (rowHeadersVisible) {
3105 Rectangle rowHeaderBounds = bounds;
3106 rowHeaderBounds.Height = row.Height;
3107 rowHeaderBounds.Width = rowHeadersWidth;
3108 DataGridViewCell cell = row.HeaderCell;
3109 DataGridViewCellStyle style = rowHeadersDefaultCellStyle;
3110 DataGridViewAdvancedBorderStyle intermediateBorderStyle = (DataGridViewAdvancedBorderStyle) ((ICloneable)this.AdvancedRowHeadersBorderStyle).Clone();
3111 DataGridViewAdvancedBorderStyle borderStyle = cell.AdjustCellBorderStyle(this.AdvancedRowHeadersBorderStyle, intermediateBorderStyle, true, true, false, cell.RowIndex == 0);
3112 cell.InternalPaint(e.Graphics, e.ClipRectangle, rowHeaderBounds, cell.RowIndex, cell.State, cell.Value, cell.FormattedValue, cell.ErrorText, style, borderStyle, DataGridViewPaintParts.All);
3113 //e.Graphics.FillRectangle(new SolidBrush(rowHeadersDefaultCellStyle.BackColor), rowHeadersBounds);
3114 bounds.X += rowHeadersWidth;
3116 bounds.Height = row.Height;
3117 for (int j = 0; j < sortedColumns.Count; j++) {
3118 DataGridViewColumn col = (DataGridViewColumn) sortedColumns[j];
3119 foreach (DataGridViewCell cell in row.Cells) {
3120 if (cell.ColumnIndex == col.Index) {
3121 bounds.Width = col.Width;
3122 cell.SetSize(new Size(bounds.Width, bounds.Height));
3123 DataGridViewCellStyle style = cell.InheritedStyle;
3124 if (cell == currentCell && cell.IsInEditMode) {
3125 cell.InitializeEditingControl(cell.RowIndex, cell.FormattedValue, style);
3126 cell.PositionEditingControl(true, true, bounds, e.ClipRectangle, style, false, false, (columns[currentCell.ColumnIndex].DisplayIndex == 0), (currentCell.RowIndex == 0));
3129 DataGridViewAdvancedBorderStyle intermediateBorderStyle = (DataGridViewAdvancedBorderStyle) ((ICloneable)this.AdvancedCellBorderStyle).Clone();
3130 DataGridViewAdvancedBorderStyle borderStyle = cell.AdjustCellBorderStyle(this.AdvancedCellBorderStyle, intermediateBorderStyle, true, true, j == 0, cell.RowIndex == 0);
3131 OnCellFormatting(new DataGridViewCellFormattingEventArgs(cell.ColumnIndex, cell.RowIndex, cell.Value, cell.FormattedValueType, style));
3132 DataGridViewCellPaintingEventArgs args = new DataGridViewCellPaintingEventArgs (this, e.Graphics, e.ClipRectangle, bounds, cell.RowIndex, cell.ColumnIndex, cell.State, cell.Value, cell.FormattedValue, cell.ErrorText, style, borderStyle, DataGridViewPaintParts.All);
3133 OnCellPainting(args);
3134 if (!args.Handled) {
3135 cell.InternalPaint(e.Graphics, e.ClipRectangle, bounds, cell.RowIndex, cell.State, cell.Value, cell.FormattedValue, cell.ErrorText, style, borderStyle, DataGridViewPaintParts.All);
3138 bounds.X += bounds.Width;
3142 bounds.Y += bounds.Height;
3143 bounds.X = -horizontalScrollingOffset;
3146 if (rowHeadersVisible) {
3147 gridWidth += rowHeadersWidth;
3149 if (columnHeadersVisible) {
3150 gridHeight += columnHeadersHeight;
3152 horizontalScrollBar.Visible = false;
3153 verticalScrollBar.Visible = false;
3155 if (gridWidth > Size.Width || gridHeight > Size.Height) {
3156 Size = new Size(gridWidth, gridHeight);
3160 if (gridWidth > Size.Width) {
3161 horizontalScrollBar.Visible = true;
3163 if (gridHeight > Size.Height) {
3164 verticalScrollBar.Visible = true;
3166 if (horizontalScrollBar.Visible && (gridHeight + horizontalScrollBar.Height) > Size.Height) {
3167 verticalScrollBar.Visible = true;
3169 if (verticalScrollBar.Visible && (gridWidth + horizontalScrollBar.Width) > Size.Width) {
3170 horizontalScrollBar.Visible = true;
3172 if (horizontalScrollBar.Visible) {
3173 horizontalScrollBar.Minimum = 0;
3174 if (verticalScrollBar.Visible) {
3175 horizontalScrollBar.Maximum = gridWidth - ClientRectangle.Width + verticalScrollBar.Width;
3178 horizontalScrollBar.Maximum = gridWidth - ClientRectangle.Width;
3180 horizontalScrollBar.LargeChange = horizontalScrollBar.Maximum / 10;
3181 horizontalScrollBar.SmallChange = horizontalScrollBar.Maximum / 20;
3183 if (verticalScrollBar.Visible) {
3184 verticalScrollBar.Minimum = 0;
3185 if (horizontalScrollBar.Visible) {
3186 verticalScrollBar.Maximum = gridHeight - ClientRectangle.Height + horizontalScrollBar.Height;
3189 verticalScrollBar.Maximum = gridHeight - ClientRectangle.Height;
3191 verticalScrollBar.LargeChange = verticalScrollBar.Maximum / 10;
3192 verticalScrollBar.SmallChange = verticalScrollBar.Maximum / 20;
3195 if (horizontalScrollBar.Visible && !this.Controls.Contains(horizontalScrollBar)) {
3196 this.Controls.Add(horizontalScrollBar);
3198 else if (!horizontalScrollBar.Visible && this.Controls.Contains(horizontalScrollBar)) {
3199 this.Controls.Remove(horizontalScrollBar);
3201 if (verticalScrollBar.Visible && !this.Controls.Contains(verticalScrollBar)) {
3202 this.Controls.Add(verticalScrollBar);
3204 else if (!verticalScrollBar.Visible && this.Controls.Contains(verticalScrollBar)) {
3205 this.Controls.Remove(verticalScrollBar);
3209 protected virtual void OnReadOnlyChanged (EventArgs e) {
3210 EventHandler eh = (EventHandler)(Events [ReadOnlyChangedEvent]);
3215 protected override void OnResize (EventArgs e) {
3217 horizontalScrollingOffset = ((gridWidth - Size.Width) > 0)? (gridWidth - Size.Width) : 0;
3218 verticalScrollingOffset = ((gridHeight - Size.Height) > 0)? (gridHeight - Size.Height) : 0;
3222 protected override void OnRightToLeftChanged (EventArgs e) {
3223 base.OnRightToLeftChanged(e);
3226 // In MSDN2 documentation there's no internal here
3227 protected internal virtual void OnRowContextMenuStripChanged (DataGridViewRowEventArgs e)
3229 DataGridViewRowEventHandler eh = (DataGridViewRowEventHandler)(Events [RowContextMenuStripChangedEvent]);
3230 if (eh != null) eh (this, e);
3233 protected virtual void OnRowContextMenuStripNeeded (DataGridViewRowContextMenuStripNeededEventArgs e)
3235 DataGridViewRowContextMenuStripNeededEventHandler eh = (DataGridViewRowContextMenuStripNeededEventHandler)(Events [RowContextMenuStripNeededEvent]);
3236 if (eh != null) eh (this, e);
3239 protected internal virtual void OnRowDefaultCellStyleChanged (DataGridViewRowEventArgs e)
3241 DataGridViewRowEventHandler eh = (DataGridViewRowEventHandler)(Events [RowDefaultCellStyleChangedEvent]);
3242 if (eh != null) eh (this, e);
3245 protected virtual void OnRowDirtyStateNeeded (QuestionEventArgs e)
3247 QuestionEventHandler eh = (QuestionEventHandler)(Events [RowDirtyStateNeededEvent]);
3248 if (eh != null) eh (this, e);
3251 protected virtual void OnRowDividerDoubleClick (DataGridViewRowDividerDoubleClickEventArgs e)
3253 DataGridViewRowDividerDoubleClickEventHandler eh = (DataGridViewRowDividerDoubleClickEventHandler)(Events [RowDividerDoubleClickEvent]);
3254 if (eh != null) eh (this, e);
3257 protected virtual void OnRowDividerHeightChanged (DataGridViewRowEventArgs e)
3259 DataGridViewRowEventHandler eh = (DataGridViewRowEventHandler)(Events [RowDividerHeightChangedEvent]);
3260 if (eh != null) eh (this, e);
3263 protected virtual void OnRowEnter (DataGridViewCellEventArgs e)
3265 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [RowEnterEvent]);
3266 if (eh != null) eh (this, e);
3269 protected internal virtual void OnRowErrorTextChanged (DataGridViewRowEventArgs e)
3271 DataGridViewRowEventHandler eh = (DataGridViewRowEventHandler)(Events [RowErrorTextChangedEvent]);
3272 if (eh != null) eh (this, e);
3275 protected virtual void OnRowErrorTextNeeded (DataGridViewRowErrorTextNeededEventArgs e)
3277 DataGridViewRowErrorTextNeededEventHandler eh = (DataGridViewRowErrorTextNeededEventHandler)(Events [RowErrorTextNeededEvent]);
3278 if (eh != null) eh (this, e);
3281 protected internal virtual void OnRowHeaderCellChanged (DataGridViewRowEventArgs e)
3283 DataGridViewRowEventHandler eh = (DataGridViewRowEventHandler)(Events [RowHeaderCellChangedEvent]);
3284 if (eh != null) eh (this, e);
3287 protected virtual void OnRowHeaderMouseClick (DataGridViewCellMouseEventArgs e)
3289 DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [RowHeaderMouseClickEvent]);
3290 if (eh != null) eh (this, e);
3293 protected virtual void OnRowHeaderMouseDoubleClick (DataGridViewCellMouseEventArgs e)
3295 DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [RowHeaderMouseDoubleClickEvent]);
3296 if (eh != null) eh (this, e);
3299 protected virtual void OnRowHeadersBorderStyleChanged (EventArgs e)
3301 EventHandler eh = (EventHandler)(Events [RowHeadersBorderStyleChangedEvent]);
3302 if (eh != null) eh (this, e);
3305 protected virtual void OnRowHeadersDefaultCellStyleChanged (EventArgs e)
3307 EventHandler eh = (EventHandler)(Events [RowHeadersDefaultCellStyleChangedEvent]);
3308 if (eh != null) eh (this, e);
3311 protected virtual void OnRowHeadersWidthChanged (EventArgs e)
3313 EventHandler eh = (EventHandler)(Events [RowHeadersWidthChangedEvent]);
3314 if (eh != null) eh (this, e);
3317 protected virtual void OnRowHeadersWidthSizeModeChanged (DataGridViewAutoSizeModeEventArgs e)
3319 DataGridViewAutoSizeModeEventHandler eh = (DataGridViewAutoSizeModeEventHandler)(Events [RowHeadersWidthSizeModeChangedEvent]);
3320 if (eh != null) eh (this, e);
3323 protected internal virtual void OnRowHeightChanged (DataGridViewRowEventArgs e)
3325 DataGridViewRowEventHandler eh = (DataGridViewRowEventHandler)(Events [RowHeightChangedEvent]);
3326 if (eh != null) eh (this, e);
3329 protected virtual void OnRowHeightInfoNeeded (DataGridViewRowHeightInfoNeededEventArgs e)
3331 DataGridViewRowHeightInfoNeededEventHandler eh = (DataGridViewRowHeightInfoNeededEventHandler)(Events [RowHeightInfoNeededEvent]);
3332 if (eh != null) eh (this, e);
3335 protected virtual void OnRowHeightInfoPushed (DataGridViewRowHeightInfoPushedEventArgs e)
3337 DataGridViewRowHeightInfoPushedEventHandler eh = (DataGridViewRowHeightInfoPushedEventHandler)(Events [RowHeightInfoPushedEvent]);
3338 if (eh != null) eh (this, e);
3341 protected virtual void OnRowLeave (DataGridViewCellEventArgs e)
3343 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [RowLeaveEvent]);
3344 if (eh != null) eh (this, e);
3347 protected internal virtual void OnRowMinimumHeightChanged (DataGridViewRowEventArgs e)
3349 DataGridViewRowEventHandler eh = (DataGridViewRowEventHandler)(Events [RowMinimumHeightChangedEvent]);
3350 if (eh != null) eh (this, e);
3353 protected internal virtual void OnRowPostPaint (DataGridViewRowPostPaintEventArgs e)
3355 DataGridViewRowPostPaintEventHandler eh = (DataGridViewRowPostPaintEventHandler)(Events [RowPostPaintEvent]);
3356 if (eh != null) eh (this, e);
3359 protected internal virtual void OnRowPrePaint (DataGridViewRowPrePaintEventArgs e)
3361 DataGridViewRowPrePaintEventHandler eh = (DataGridViewRowPrePaintEventHandler)(Events [RowPrePaintEvent]);
3362 if (eh != null) eh (this, e);
3365 protected internal virtual void OnRowsAdded (DataGridViewRowsAddedEventArgs e)
3367 DataGridViewRowsAddedEventHandler eh = (DataGridViewRowsAddedEventHandler)(Events [RowsAddedEvent]);
3368 if (eh != null) eh (this, e);
3371 protected virtual void OnRowsDefaultCellStyleChanged (EventArgs e)
3373 EventHandler eh = (EventHandler)(Events [RowsDefaultCellStyleChangedEvent]);
3374 if (eh != null) eh (this, e);
3377 protected internal virtual void OnRowsRemoved (DataGridViewRowsRemovedEventArgs e)
3379 DataGridViewRowsRemovedEventHandler eh = (DataGridViewRowsRemovedEventHandler)(Events [RowsRemovedEvent]);
3380 if (eh != null) eh (this, e);
3383 protected internal virtual void OnRowStateChanged (int rowIndex, DataGridViewRowStateChangedEventArgs e)
3385 DataGridViewRowStateChangedEventHandler eh = (DataGridViewRowStateChangedEventHandler)(Events [RowStateChangedEvent]);
3386 if (eh != null) eh (this, e);
3389 protected virtual void OnRowUnshared (DataGridViewRowEventArgs e)
3391 DataGridViewRowEventHandler eh = (DataGridViewRowEventHandler)(Events [RowUnsharedEvent]);
3392 if (eh != null) eh (this, e);
3395 protected virtual void OnRowValidated (DataGridViewCellEventArgs e)
3397 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [RowValidatedEvent]);
3398 if (eh != null) eh (this, e);
3401 protected virtual void OnRowValidating (DataGridViewCellCancelEventArgs e)
3403 DataGridViewCellCancelEventHandler eh = (DataGridViewCellCancelEventHandler)(Events [RowValidatingEvent]);
3404 if (eh != null) eh (this, e);
3407 protected virtual void OnScroll (ScrollEventArgs e)
3409 ScrollEventHandler eh = (ScrollEventHandler)(Events [ScrollEvent]);
3410 if (eh != null) eh (this, e);
3413 protected virtual void OnSelectionChanged (EventArgs e)
3415 EventHandler eh = (EventHandler)(Events [SelectionChangedEvent]);
3416 if (eh != null) eh (this, e);
3419 protected virtual void OnSortCompare (DataGridViewSortCompareEventArgs e) {
3420 DataGridViewSortCompareEventHandler eh = (DataGridViewSortCompareEventHandler)(Events [SortCompareEvent]);
3421 if (eh != null) eh (this, e);
3424 protected virtual void OnSorted (EventArgs e)
3426 EventHandler eh = (EventHandler)(Events [SortedEvent]);
3427 if (eh != null) eh (this, e);
3430 protected virtual void OnUserAddedRow (DataGridViewRowEventArgs e)
3432 DataGridViewRowEventHandler eh = (DataGridViewRowEventHandler)(Events [UserAddedRowEvent]);
3433 if (eh != null) eh (this, e);
3436 protected virtual void OnUserDeletedRow (DataGridViewRowEventArgs e)
3438 DataGridViewRowEventHandler eh = (DataGridViewRowEventHandler)(Events [UserDeletedRowEvent]);
3439 if (eh != null) eh (this, e);
3443 protected virtual void OnUserDeletingRow (DataGridViewRowCancelEventArgs e)
3445 DataGridViewRowCancelEventHandler eh = (DataGridViewRowCancelEventHandler)(Events [UserDeletingRowEvent]);
3446 if (eh != null) eh (this, e);
3449 protected override void OnValidating (CancelEventArgs e)
3451 base.OnValidating(e);
3454 protected override void OnVisibleChanged (EventArgs e)
3456 base.OnVisibleChanged(e);
3459 protected virtual void PaintBackground (Graphics graphics, Rectangle clipBounds, Rectangle gridBounds)
3463 protected bool ProcessAKey (Keys keyData)
3465 throw new NotImplementedException();
3468 protected virtual bool ProcessDataGridViewKey (KeyEventArgs e)
3470 throw new NotImplementedException();
3473 protected bool ProcessDeleteKey (Keys keyData)
3475 throw new NotImplementedException();
3478 protected override bool ProcessDialogKey (Keys keyData)
3480 return base.ProcessDialogKey(keyData);
3481 //throw new NotImplementedException();
3484 protected bool ProcessDownKey (Keys keyData) {
3485 throw new NotImplementedException();
3488 protected bool ProcessEndKey (Keys keyData) {
3489 throw new NotImplementedException();
3492 protected bool ProcessEnterKey (Keys keyData) {
3493 throw new NotImplementedException();
3496 protected bool ProcessEscapeKey (Keys keyData) {
3497 throw new NotImplementedException();
3500 protected bool ProcessF2Key (Keys keyData) {
3501 throw new NotImplementedException();
3504 protected bool ProcessHomeKey (Keys keyData) {
3505 throw new NotImplementedException();
3508 protected bool ProcessInsertKey (Keys keyData) {
3509 throw new NotImplementedException();
3512 protected override bool ProcessKeyEventArgs (ref Message m) {
3513 return base.ProcessKeyEventArgs(ref m);
3514 //throw new NotImplementedException();
3517 protected override bool ProcessKeyPreview (ref Message m) {
3518 return base.ProcessKeyPreview(ref m);
3519 //throw new NotImplementedException();
3522 protected bool ProcessLeftKey (Keys keyData) {
3523 throw new NotImplementedException();
3526 protected bool ProcessNextKey (Keys keyData) {
3528 throw new NotImplementedException();
3531 protected bool ProcessPriorKey (Keys keyData) {
3533 throw new NotImplementedException();
3536 protected bool ProcessRightKey (Keys keyData) {
3537 throw new NotImplementedException();
3540 protected bool ProcessSpaceKey (Keys keyData) {
3541 throw new NotImplementedException();
3544 protected bool ProcessTabKey (Keys keyData) {
3545 throw new NotImplementedException();
3548 protected bool ProcessUpKey (Keys keyData) {
3549 throw new NotImplementedException();
3552 protected bool ProcessZeroKey (Keys keyData) {
3553 throw new NotImplementedException();
3556 protected override void SetBoundsCore (int x, int y, int width, int height, BoundsSpecified specified) {
3557 base.SetBoundsCore(x, y, width, height, specified);
3560 protected virtual bool SetCurrentCellAddressCore (int columnIndex, int rowIndex, bool setAnchorCellAddress, bool validateCurrentCell, bool throughMouseClick) {
3561 throw new NotImplementedException();
3564 protected virtual void SetSelectedCellCore (int columnIndex, int rowIndex, bool selected) {
3565 throw new NotImplementedException();
3568 protected virtual void SetSelectedColumnCore (int columnIndex, bool selected) {
3569 throw new NotImplementedException();
3572 protected virtual void SetSelectedRowCore (int rowIndex, bool selected) {
3573 throw new NotImplementedException();
3576 protected override void WndProc (ref Message m) {
3577 base.WndProc(ref m);
3580 void IDropTarget.OnDragDrop (DragEventArgs e)
3582 throw new NotImplementedException ();
3585 void IDropTarget.OnDragEnter (DragEventArgs e)
3587 throw new NotImplementedException ();
3590 void IDropTarget.OnDragLeave (EventArgs e)
3592 throw new NotImplementedException ();
3595 void IDropTarget.OnDragOver (DragEventArgs e)
3597 throw new NotImplementedException ();
3600 internal void InternalOnCellClick (DataGridViewCellEventArgs e) {
3604 internal void InternalOnCellContentClick (DataGridViewCellEventArgs e) {
3605 OnCellContentClick(e);
3608 internal void InternalOnCellContentDoubleClick (DataGridViewCellEventArgs e) {
3609 OnCellContentDoubleClick(e);
3612 internal void InternalOnCellValueChanged (DataGridViewCellEventArgs e) {
3613 OnCellValueChanged(e);
3616 internal void InternalOnDataError (DataGridViewDataErrorEventArgs e) {
3617 /////////////// false? ////////////
3618 OnDataError(false, e);
3621 internal void InternalOnMouseWheel (MouseEventArgs e) {
3625 internal void OnHScrollBarScroll (object sender, ScrollEventArgs e) {
3626 horizontalScrollingOffset = e.NewValue;
3631 internal void OnVScrollBarScroll (object sender, ScrollEventArgs e) {
3632 verticalScrollingOffset = e.NewValue;
3637 internal void RaiseCellStyleChanged (DataGridViewCellEventArgs e) {
3638 OnCellStyleChanged(e);
3641 internal void OnColumnCollectionChanged (object sender, CollectionChangeEventArgs e) {
3643 case CollectionChangeAction.Add:
3644 OnColumnAdded(new DataGridViewColumnEventArgs(e.Element as DataGridViewColumn));
3646 case CollectionChangeAction.Remove:
3647 OnColumnRemoved(new DataGridViewColumnEventArgs(e.Element as DataGridViewColumn));
3649 case CollectionChangeAction.Refresh:
3654 private void BindIList (IList list) {
3655 if (list.Count > 0) {
3656 DataGridViewCell template = new DataGridViewTextBoxCell();
3657 foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(list[0])) {
3658 DataGridViewColumn col = new DataGridViewColumn(template);
3659 col.Name = property.DisplayName;
3663 foreach (object element in list) {
3664 DataGridViewRow row = new DataGridViewRow();
3665 rows.InternalAdd(row);
3666 PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(element);
3667 foreach (PropertyDescriptor property in properties) {
3668 DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell();
3669 cell.Value = property.GetValue(element);
3670 cell.ValueType = property.PropertyType;
3671 row.Cells.Add(cell);
3676 private void BindIListSource (IListSource list) {
3677 BindIList(list.GetList());
3680 private void BindIBindingList (IBindingList list) {
3684 private void BindIBindingListView (IBindingListView list) {
3688 public sealed class HitTestInfo {
3690 public static readonly HitTestInfo Nowhere = new HitTestInfo(-1, -1, -1, -1, DataGridViewHitTestType.None);
3692 private int columnIndex;
3693 private int columnX;
3694 private int rowIndex;
3696 private DataGridViewHitTestType type;
3698 internal HitTestInfo (int columnIndex, int columnX, int rowIndex, int rowY, DataGridViewHitTestType type) {
3699 this.columnIndex = columnIndex;
3700 this.columnX = columnX;
3701 this.rowIndex = rowIndex;
3706 public int ColumnIndex {
3707 get { return columnIndex; }
3710 public int ColumnX {
3711 get { return columnX; }
3714 public int RowIndex {
3715 get { return rowIndex; }
3719 get { return rowY; }
3722 public DataGridViewHitTestType Type {
3723 get { return type; }
3726 public override bool Equals (object value) {
3727 if (value is HitTestInfo) {
3728 HitTestInfo aux = (HitTestInfo) value;
3729 if (aux.columnIndex == columnIndex && aux.columnX == columnX && aux.rowIndex == rowIndex && aux.rowY == rowY && aux.type == type) {
3736 public override int GetHashCode () {
3737 return base.GetHashCode();
3740 public override string ToString () {
3741 return GetType().Name;
3746 [ComVisibleAttribute(true)]
3747 protected class DataGridViewAccessibleObject : ControlAccessibleObject {
3749 public DataGridViewAccessibleObject (DataGridView owner) : base (owner){
3752 public override AccessibleRole Role {
3753 get { return base.Role; }
3756 public override AccessibleObject GetChild (int index) {
3757 return base.GetChild(index);
3760 public override int GetChildCount () {
3761 return base.GetChildCount();
3764 public override AccessibleObject GetFocused () {
3765 return base.GetFocused();
3768 public override AccessibleObject GetSelected () {
3769 return base.GetSelected();
3772 public override AccessibleObject HitTest (int x, int y) {
3773 return base.HitTest(x, y);
3776 public override AccessibleObject Navigate( AccessibleNavigation navigationDirection) {
3777 return base.Navigate(navigationDirection);