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;
37 namespace System.Windows.Forms {
39 [ComVisibleAttribute(true)]
40 [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
41 [Designer("System.Windows.Forms.Design.DataGridViewDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
42 [Editor("System.Windows.Forms.Design.DataGridViewComponentEditor, " + Consts.AssemblySystem_Design, typeof (System.ComponentModel.ComponentEditor))]
43 [ComplexBindingProperties ("DataSource", "DataMember")]
44 [DefaultEvent ("CellContentClick")]
45 [Docking (DockingBehavior.Ask)]
46 public class DataGridView : Control, ISupportInitialize, IBindableComponent, IDropTarget
49 private DataGridViewAdvancedBorderStyle adjustedTopLeftHeaderBorderStyle;
50 private DataGridViewAdvancedBorderStyle advancedCellBorderStyle;
51 private DataGridViewAdvancedBorderStyle advancedColumnHeadersBorderStyle;
52 private DataGridViewAdvancedBorderStyle advancedRowHeadersBorderStyle;
53 private bool allowUserToAddRows;
54 private bool allowUserToDeleteRows;
55 private bool allowUserToOrderColumns;
56 private bool allowUserToResizeColumns;
57 private bool allowUserToResizeRows;
58 private DataGridViewCellStyle alternatingRowsDefaultCellStyle;
59 private bool autoGenerateColumns;
60 private bool autoSize;
61 private DataGridViewAutoSizeColumnsMode autoSizeColumnsMode;
62 private DataGridViewAutoSizeRowsMode autoSizeRowsMode;
63 private Color backColor;
64 private Color backgroundColor;
65 private Image backgroundImage;
66 private BorderStyle borderStyle;
67 private DataGridViewCellBorderStyle cellBorderStyle;
68 private DataGridViewClipboardCopyMode clipboardCopyMode;
69 private DataGridViewHeaderBorderStyle columnHeadersBorderStyle;
70 private DataGridViewCellStyle columnHeadersDefaultCellStyle;
71 private int columnHeadersHeight;
72 private DataGridViewColumnHeadersHeightSizeMode columnHeadersHeightSizeMode;
73 private bool columnHeadersVisible;
74 private DataGridViewColumnCollection columns;
75 private DataGridViewCell currentCell;
76 private Point currentCellAddress;
77 private DataGridViewRow currentRow;
78 private string dataMember;
79 private object dataSource;
80 private DataGridViewCellStyle defaultCellStyle;
81 //private Control editingControl;
82 private DataGridViewEditMode editMode;
83 private bool enableHeadersVisualStyles;
84 private DataGridViewCell firstDisplayedCell;
85 private int firstDisplayedScrollingColumnHiddenWidth;
86 private int firstDisplayedScrollingColumnIndex;
87 private int firstDisplayedScrollingRowIndex;
88 private Color gridColor = Color.FromKnownColor(KnownColor.ControlDark);
89 private int horizontalScrollingOffset;
90 private bool isCurrentCellDirty;
91 //private bool isCurrentRowDirty;
92 private bool multiSelect;
93 private bool readOnly;
94 private DataGridViewHeaderBorderStyle rowHeadersBorderStyle;
95 private DataGridViewCellStyle rowHeadersDefaultCellStyle;
96 private bool rowHeadersVisible;
97 private int rowHeadersWidth;
98 private DataGridViewRowHeadersWidthSizeMode rowHeadersWidthSizeMode;
99 private DataGridViewRowCollection rows;
100 private DataGridViewCellStyle rowsDefaultCellStyle;
101 private DataGridViewRow rowTemplate;
102 private ScrollBars scrollBars;
103 private DataGridViewSelectionMode selectionMode;
104 private bool showCellErrors;
105 private bool showCellToolTips;
106 private bool showEditingIcon;
107 private bool showRowErrors;
108 private DataGridViewColumn sortedColumn = null;
109 private SortOrder sortOrder;
110 private bool standardTab;
111 private DataGridViewHeaderCell topLeftHeaderCell;
112 private Cursor userSetCursor;
113 private int verticalScrollingOffset;
114 private bool virtualMode;
115 private HScrollBar horizontalScrollBar;
116 private VScrollBar verticalScrollBar;
118 internal int gridWidth;
119 internal int gridHeight;
121 public DataGridView () {
122 adjustedTopLeftHeaderBorderStyle = new DataGridViewAdvancedBorderStyle();
123 adjustedTopLeftHeaderBorderStyle.All = DataGridViewAdvancedCellBorderStyle.Single;
124 advancedCellBorderStyle = new DataGridViewAdvancedBorderStyle();
125 advancedCellBorderStyle.All = DataGridViewAdvancedCellBorderStyle.Single;
126 advancedColumnHeadersBorderStyle = new DataGridViewAdvancedBorderStyle();
127 advancedColumnHeadersBorderStyle.All = DataGridViewAdvancedCellBorderStyle.Single;
128 advancedRowHeadersBorderStyle = new DataGridViewAdvancedBorderStyle();
129 advancedRowHeadersBorderStyle.All = DataGridViewAdvancedCellBorderStyle.Single;
130 alternatingRowsDefaultCellStyle = new DataGridViewCellStyle();
131 allowUserToAddRows = true;
132 allowUserToDeleteRows = true;
133 allowUserToOrderColumns = false;
134 allowUserToResizeColumns = true;
135 allowUserToResizeRows = true;
136 autoGenerateColumns = true;
137 autoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
138 autoSizeRowsMode = DataGridViewAutoSizeRowsMode.None;
139 backColor = Control.DefaultBackColor;
140 backgroundColor = SystemColors.AppWorkspace;
141 borderStyle = BorderStyle.FixedSingle;
142 cellBorderStyle = DataGridViewCellBorderStyle.None;
143 clipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithAutoHeaderText;
144 columnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
145 columnHeadersDefaultCellStyle = new DataGridViewCellStyle();
146 columnHeadersDefaultCellStyle.BackColor = SystemColors.Control;
147 columnHeadersDefaultCellStyle.ForeColor = SystemColors.WindowText;
148 columnHeadersDefaultCellStyle.SelectionBackColor = SystemColors.Highlight;
149 columnHeadersDefaultCellStyle.SelectionForeColor = SystemColors.HighlightText;
150 columnHeadersDefaultCellStyle.Font = this.Font;
151 columnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
152 columnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.True;
153 columnHeadersHeight = 23;
154 columnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing;
155 columnHeadersVisible = true;
156 columns = CreateColumnsInstance();
157 columns.CollectionChanged += OnColumnCollectionChanged;
158 dataMember = String.Empty;
159 defaultCellStyle = new DataGridViewCellStyle();
160 defaultCellStyle.BackColor = SystemColors.Window;
161 defaultCellStyle.ForeColor = SystemColors.ControlText;
162 defaultCellStyle.SelectionBackColor = SystemColors.Highlight;
163 defaultCellStyle.SelectionForeColor = SystemColors.HighlightText;
164 defaultCellStyle.Font = this.Font;
165 defaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
166 defaultCellStyle.WrapMode = DataGridViewTriState.False;
167 editMode = DataGridViewEditMode.EditOnKeystrokeOrF2;
170 rowHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
171 rowHeadersDefaultCellStyle = (DataGridViewCellStyle) columnHeadersDefaultCellStyle.Clone ();
172 rowHeadersVisible = true;
173 rowHeadersWidth = 41;
174 rowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.EnableResizing;
175 rows = CreateRowsInstance();
176 rowsDefaultCellStyle = new DataGridViewCellStyle();
177 selectionMode = DataGridViewSelectionMode.RowHeaderSelect;
178 showCellErrors = true;
179 showEditingIcon = true;
180 userSetCursor = Cursor.Current;
183 horizontalScrollBar = new HScrollBar();
184 horizontalScrollBar.Dock = DockStyle.Bottom;
185 horizontalScrollBar.Scroll += OnHScrollBarScroll;
186 horizontalScrollBar.Visible = false;
187 verticalScrollBar = new VScrollBar();
188 verticalScrollBar.Dock = DockStyle.Right;
189 verticalScrollBar.Scroll += OnVScrollBarScroll;
190 verticalScrollBar.Visible = false;
193 void ISupportInitialize.BeginInit ()
197 void ISupportInitialize.EndInit ()
204 [EditorBrowsable (EditorBrowsableState.Advanced)]
205 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
206 public virtual DataGridViewAdvancedBorderStyle AdjustedTopLeftHeaderBorderStyle {
207 get { return adjustedTopLeftHeaderBorderStyle; }
211 [EditorBrowsable (EditorBrowsableState.Advanced)]
212 public DataGridViewAdvancedBorderStyle AdvancedCellBorderStyle {
213 get { return advancedCellBorderStyle; }
217 [EditorBrowsable (EditorBrowsableState.Advanced)]
218 public DataGridViewAdvancedBorderStyle AdvancedColumnHeadersBorderStyle {
219 get { return advancedColumnHeadersBorderStyle; }
223 [EditorBrowsable (EditorBrowsableState.Advanced)]
224 public DataGridViewAdvancedBorderStyle AdvancedRowHeadersBorderStyle {
225 get { return advancedRowHeadersBorderStyle; }
228 [DefaultValue (true)]
229 public bool AllowUserToAddRows {
230 get { return allowUserToAddRows; }
232 if (allowUserToAddRows != value) {
233 allowUserToAddRows = value;
234 OnAllowUserToAddRowsChanged(EventArgs.Empty);
239 [DefaultValue (true)]
240 public bool AllowUserToDeleteRows {
241 get { return allowUserToDeleteRows; }
243 if (allowUserToDeleteRows != value) {
244 allowUserToDeleteRows = value;
245 OnAllowUserToDeleteRowsChanged(EventArgs.Empty);
250 [DefaultValue (false)]
251 public bool AllowUserToOrderColumns {
252 get { return allowUserToOrderColumns; }
254 if (allowUserToOrderColumns != value) {
255 allowUserToOrderColumns = value;
256 OnAllowUserToOrderColumnsChanged(EventArgs.Empty);
261 [DefaultValue (true)]
262 public bool AllowUserToResizeColumns {
263 get { return allowUserToResizeColumns; }
265 if (allowUserToResizeColumns != value) {
266 allowUserToResizeColumns = value;
267 OnAllowUserToResizeColumnsChanged(EventArgs.Empty);
272 [DefaultValue (true)]
273 public bool AllowUserToResizeRows {
274 get { return allowUserToResizeRows; }
276 if (allowUserToResizeRows != value) {
277 allowUserToResizeRows = value;
278 OnAllowUserToResizeRowsChanged(EventArgs.Empty);
283 public DataGridViewCellStyle AlternatingRowsDefaultCellStyle {
284 get { return alternatingRowsDefaultCellStyle; }
286 if (alternatingRowsDefaultCellStyle != value) {
287 alternatingRowsDefaultCellStyle = value;
288 OnAlternatingRowsDefaultCellStyleChanged(EventArgs.Empty);
295 [EditorBrowsable (EditorBrowsableState.Advanced)]
296 [DefaultValue (true)]
297 public bool AutoGenerateColumns {
298 get { return autoGenerateColumns; }
300 if (autoGenerateColumns != value) {
301 autoGenerateColumns = value;
302 OnAutoGenerateColumnsChanged(EventArgs.Empty);
307 public override bool AutoSize {
308 get { return autoSize; }
310 if (autoSize != value) {
312 //OnAutoSizeChanged(EventArgs.Empty);
317 [DefaultValue (DataGridViewAutoSizeColumnsMode.None)]
318 public DataGridViewAutoSizeColumnsMode AutoSizeColumnsMode {
319 get { return autoSizeColumnsMode; }
321 if (!Enum.IsDefined(typeof(DataGridViewAutoSizeColumnsMode), value)) {
322 throw new InvalidEnumArgumentException("Value is not valid DataGridViewAutoSizeColumnsMode.");
324 if (value == DataGridViewAutoSizeColumnsMode.ColumnHeader && columnHeadersVisible == false) {
325 foreach (DataGridViewColumn col in columns) {
326 if (col.AutoSizeMode == DataGridViewAutoSizeColumnMode.NotSet) {
327 throw new InvalidOperationException("Cant set this property to ColumnHeader in this DataGridView.");
331 if (value == DataGridViewAutoSizeColumnsMode.Fill) {
332 foreach (DataGridViewColumn col in columns) {
333 if (col.AutoSizeMode == DataGridViewAutoSizeColumnMode.NotSet) {
335 throw new InvalidOperationException("Cant set this property to Fill in this DataGridView.");
340 autoSizeColumnsMode = value;
344 [DefaultValue (DataGridViewAutoSizeRowsMode.None)]
345 public DataGridViewAutoSizeRowsMode AutoSizeRowsMode {
346 get { return autoSizeRowsMode; }
348 if (autoSizeRowsMode != value) {
349 if (!Enum.IsDefined(typeof(DataGridViewAutoSizeRowsMode), value)) {
350 throw new InvalidEnumArgumentException("Value is not valid DataGridViewRowsMode.");
352 if ((value == DataGridViewAutoSizeRowsMode.AllHeaders || value == DataGridViewAutoSizeRowsMode.DisplayedHeaders) && rowHeadersVisible == false) {
353 throw new InvalidOperationException("Cant set this property to AllHeaders or DisplayedHeaders in this DataGridView.");
355 autoSizeRowsMode = value;
356 OnAutoSizeRowsModeChanged(new DataGridViewAutoSizeModeEventArgs(false));
357 ////////////////////////////////////////////////////////////////
363 [EditorBrowsable (EditorBrowsableState.Never)]
364 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
365 public override Color BackColor {
366 get { return backColor; }
368 if (backColor != value) {
370 OnBackColorChanged(EventArgs.Empty);
375 public Color BackgroundColor {
376 get { return backgroundColor; }
378 if (backgroundColor != value) {
379 if (value == Color.Empty) {
380 throw new ArgumentException("Cant set an Empty color.");
382 backgroundColor = value;
383 OnBackgroundColorChanged(EventArgs.Empty);
389 [EditorBrowsable (EditorBrowsableState.Never)]
390 public override Image BackgroundImage {
391 get { return backgroundImage; }
393 if (backgroundImage != value) {
394 backgroundImage = value;
395 OnBackgroundImageChanged(EventArgs.Empty);
401 [EditorBrowsable (EditorBrowsableState.Never)]
402 public override ImageLayout BackgroundImageLayout {
403 get { return base.BackgroundImageLayout; }
404 set { base.BackgroundImageLayout = value; }
407 [DefaultValue (BorderStyle.FixedSingle)]
408 public BorderStyle BorderStyle {
409 get { return borderStyle; }
411 if (borderStyle != value) {
412 if (!Enum.IsDefined(typeof(BorderStyle), value)) {
413 throw new InvalidEnumArgumentException("Invalid border style.");
416 OnBorderStyleChanged(EventArgs.Empty);
422 [DefaultValue (DataGridViewCellBorderStyle.Single)]
423 public DataGridViewCellBorderStyle CellBorderStyle {
424 get { return cellBorderStyle; }
426 if (cellBorderStyle != value) {
427 cellBorderStyle = value;
428 OnCellBorderStyleChanged(EventArgs.Empty);
434 [DefaultValue (DataGridViewClipboardCopyMode.EnableWithAutoHeaderText)]
435 public DataGridViewClipboardCopyMode ClipboardCopyMode {
436 get { return clipboardCopyMode; }
437 set { clipboardCopyMode = value; }
441 [EditorBrowsable (EditorBrowsableState.Advanced)]
442 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
444 public int ColumnCount {
445 get { return columns.Count; }
448 throw new ArgumentOutOfRangeException("ColumnCount",
449 "ColumnCount must be >= 0.");
451 if (dataSource != null) {
452 throw new InvalidOperationException("Cant change column count if DataSource is set.");
454 if (value < columns.Count) {
455 for (int i = value; i < columns.Count; i++) {
459 else if (value > columns.Count) {
460 for (int i = 0; i < value; i++) {
461 DataGridViewColumn col = new DataGridViewColumn();
469 [DefaultValue (DataGridViewHeaderBorderStyle.Raised)]
470 public DataGridViewHeaderBorderStyle ColumnHeadersBorderStyle {
471 get { return columnHeadersBorderStyle; }
473 if (columnHeadersBorderStyle != value) {
474 columnHeadersBorderStyle = value;
475 OnColumnHeadersBorderStyleChanged(EventArgs.Empty);
480 [AmbientValue (null)]
481 public DataGridViewCellStyle ColumnHeadersDefaultCellStyle {
482 get { return columnHeadersDefaultCellStyle; }
484 if (columnHeadersDefaultCellStyle != value) {
485 columnHeadersDefaultCellStyle = value;
486 OnColumnHeadersDefaultCellStyleChanged(EventArgs.Empty);
492 public int ColumnHeadersHeight {
493 get { return columnHeadersHeight; }
495 if (columnHeadersHeight != value) {
497 throw new ArgumentOutOfRangeException("ColumnHeadersHeight",
498 "Column headers height cant be less than 4.");
500 if (value > 32768 ) {
501 throw new ArgumentOutOfRangeException("ColumnHeadersHeight",
502 "Column headers height cannot be more than 32768.");
504 columnHeadersHeight = value;
505 OnColumnHeadersHeightChanged(EventArgs.Empty);
510 [RefreshProperties (RefreshProperties.All)]
511 [DefaultValue (DataGridViewColumnHeadersHeightSizeMode.EnableResizing)]
512 public DataGridViewColumnHeadersHeightSizeMode ColumnHeadersHeightSizeMode {
513 get { return columnHeadersHeightSizeMode; }
515 if (columnHeadersHeightSizeMode != value) {
516 if (!Enum.IsDefined(typeof(DataGridViewColumnHeadersHeightSizeMode), value)) {
517 throw new InvalidEnumArgumentException("Value is not a valid DataGridViewColumnHeadersHeightSizeMode.");
519 columnHeadersHeightSizeMode = value;
520 OnColumnHeadersHeightSizeModeChanged(new DataGridViewAutoSizeModeEventArgs(false));
525 [DefaultValue (true)]
526 public bool ColumnHeadersVisible {
527 get { return columnHeadersVisible; }
528 set { columnHeadersVisible = value; }
531 [MergableProperty (false)]
532 [Editor ("System.Windows.Forms.Design.DataGridViewColumnCollectionEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
533 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
534 public DataGridViewColumnCollection Columns {
535 get { return columns; }
539 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
540 public DataGridViewCell CurrentCell {
541 get { return currentCell; }
543 /////////////////////////////////////////////////////
544 /// *** InvalidOperationException ***
545 /// Changes to the specified cell cannot be committed
546 /// to the data cache, or the new cell is in a hidden
548 /////////////////////////////////////////////////////
549 if (value.DataGridView != this) {
550 throw new ArgumentException("The cell is not in this DataGridView.");
557 public Point CurrentCellAddress {
558 get { return currentCellAddress; }
562 public DataGridViewRow CurrentRow {
563 get { return currentRow; }
567 [Editor ("System.Windows.Forms.Design.DataMemberListEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
568 public string DataMember {
569 get { return dataMember; }
571 if (dataMember != value) {
573 OnDataMemberChanged(EventArgs.Empty);
578 [RefreshProperties (RefreshProperties.Repaint)]
579 [DefaultValue (null)]
580 [AttributeProvider (typeof (IListSource))]
581 // XXX AttributeProviderAtribute
582 public object DataSource {
583 get { return dataSource; }
585 if (dataSource != value) {
586 /* 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:
587 - the System.Collections.IList interface, including one-dimensional arrays.
588 - the System.ComponentModel.IListSource interface, such as the System.Data.DataTable and System.Data.DataSet classes.
589 - the System.ComponentModel.IBindingList interface, such as the System.ComponentModel.Collections.BindingList<> class.
590 - the System.ComponentModel.IBindingListView interface, such as the System.Windows.Forms.BindingSource class.
592 if (!(value == null || value is IList || value is IListSource || value is IBindingList || value is IBindingListView)) {
593 throw new NotSupportedException("Type cant be binded.");
595 if (dataSource != null) {
598 if (dataSource is DataView) {
599 (dataSource as DataView).ListChanged -= OnListChanged;
601 if (dataSource is DataTable) {
602 ((dataSource as IListSource).GetList() as DataView).ListChanged -= OnListChanged;
606 OnDataSourceChanged(EventArgs.Empty);
607 if (dataSource != null) {
609 if (value is IList) {
610 BindIList(value as IList);
612 else if (value is IListSource) {
613 BindIListSource(value as IListSource);
615 else if (value is IBindingList) {
616 BindIBindingList(value as IBindingList);
618 else if (value is IBindingListView) {
619 BindIBindingListView(value as IBindingListView);
620 //bool cosa = ((value as IBindingListView).SortDescriptions as IList).IsFixedSize;
622 OnDataBindingComplete(new DataGridViewBindingCompleteEventArgs(ListChangedType.Reset));
629 [AmbientValue (null)]
630 public DataGridViewCellStyle DefaultCellStyle {
631 get { return defaultCellStyle; }
633 if (defaultCellStyle != value) {
634 defaultCellStyle = value;
635 OnDefaultCellStyleChanged(EventArgs.Empty);
640 public override Rectangle DisplayRectangle {
641 get { return base.DisplayRectangle; }
645 [EditorBrowsable (EditorBrowsableState.Advanced)]
646 public Control EditingControl {
648 if (currentCell == null || !currentCell.IsInEditMode) {
651 return (Control) Activator.CreateInstance(currentCell.EditType);
656 [EditorBrowsable (EditorBrowsableState.Advanced)]
657 public Panel EditingPanel {
658 get { throw new NotImplementedException(); }
661 [DefaultValue (DataGridViewEditMode.EditOnKeystrokeOrF2)]
662 public DataGridViewEditMode EditMode {
663 get { return editMode; }
665 if (editMode != value) {
667 OnEditModeChanged(EventArgs.Empty);
672 [DefaultValue (true)]
673 public bool EnableHeadersVisualStyles {
674 get { return enableHeadersVisualStyles; }
675 set { enableHeadersVisualStyles = value; }
679 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
680 public DataGridViewCell FirstDisplayedCell {
681 get { return firstDisplayedCell; }
683 if (value.DataGridView != this) {
684 throw new ArgumentException("The cell is not in this DataGridView.");
686 firstDisplayedCell = value;
691 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
692 [EditorBrowsable (EditorBrowsableState.Advanced)]
693 public int FirstDisplayedScrollingColumnHiddenWidth {
694 get { return firstDisplayedScrollingColumnHiddenWidth; }
698 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
699 public int FirstDisplayedScrollingColumnIndex {
700 get { return firstDisplayedScrollingColumnIndex; }
701 set { firstDisplayedScrollingColumnIndex = value; }
705 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
706 public int FirstDisplayedScrollingRowIndex {
707 get { return firstDisplayedScrollingRowIndex; }
708 set { firstDisplayedScrollingRowIndex = value; }
712 [EditorBrowsable (EditorBrowsableState.Advanced)]
713 public override Font Font {
714 get { return base.Font; }
715 set { base.Font = value; }
719 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
720 [EditorBrowsable (EditorBrowsableState.Advanced)]
721 public override Color ForeColor {
722 get { return base.ForeColor; }
723 set { base.ForeColor = value; }
726 public Color GridColor {
727 get { return gridColor; }
729 if (gridColor != value) {
730 if (value == Color.Empty) {
731 throw new ArgumentException("Cant set an Empty color.");
734 OnGridColorChanged(EventArgs.Empty);
740 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
741 public int HorizontalScrollingOffset {
742 get { return horizontalScrollingOffset; }
743 set { horizontalScrollingOffset = value; }
747 public bool IsCurrentCellDirty {
748 get { return isCurrentCellDirty; }
752 public bool IsCurrentCellInEditMode {
754 if (currentCell == null) {
757 return currentCell.IsInEditMode;
762 public bool IsCurrentRowDirty {
765 return IsCurrentCellDirty;
768 throw new NotImplementedException();
773 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
774 public DataGridViewCell this [int columnIndex, int rowIndex] {
775 get { return rows[rowIndex].Cells[columnIndex]; }
776 set { rows[rowIndex].Cells[columnIndex] = value; }
780 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
781 public DataGridViewCell this [string columnName, int rowIndex] {
783 int columnIndex = -1;
784 foreach (DataGridViewColumn col in columns) {
785 if (col.Name == columnName) {
786 columnIndex = col.Index;
790 return this[columnIndex, rowIndex];
793 int columnIndex = -1;
794 foreach (DataGridViewColumn col in columns) {
795 if (col.Name == columnName) {
796 columnIndex = col.Index;
800 this[columnIndex, rowIndex] = value;
804 [DefaultValue (true)]
805 public bool MultiSelect {
806 get { return multiSelect; }
808 if (multiSelect != value) {
810 OnMultiSelectChanged(EventArgs.Empty);
816 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
817 public int NewRowIndex {
819 if (!allowUserToAddRows) {
822 return rows.Count - 1;
827 [EditorBrowsable (EditorBrowsableState.Never)]
828 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
829 public new Padding Padding {
830 get { return Padding.Empty; }
835 [DefaultValue (false)]
836 public bool ReadOnly {
837 get { return readOnly; }
839 if (readOnly != value) {
841 OnReadOnlyChanged(EventArgs.Empty);
847 [EditorBrowsable (EditorBrowsableState.Advanced)]
848 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
850 public int RowCount {
851 get { return rows.Count; }
854 throw new ArgumentException("RowCount must be >= 0.");
856 if (value < 1 && allowUserToAddRows) {
857 throw new ArgumentException("RowCount must be >= 1 if AllowUserToAddRows is true.");
859 if (dataSource != null) {
860 throw new InvalidOperationException("Cant change row count if DataSource is set.");
862 if (value < rows.Count) {
863 for (int i = value; i < rows.Count; i++) {
867 else if (value > rows.Count) {
868 for (int i = 0; i < value; i++) {
869 // DataGridViewRow row = new DataGridViewRow(); //(DataGridViewRow) rowTemplate.Clone();
870 DataGridViewRow row = (DataGridViewRow) rowTemplate.Clone();
872 foreach (DataGridViewColumn col in columns) {
873 row.Cells.Add(col.CellTemplate.Clone() as DataGridViewCell);
877 if (ColumnCount == 0) {
878 ///////////////////////////////////////////////////////////////
879 //columns.Add(new DataGridViewTextBoxColumn());
880 throw new NotImplementedException();
886 [DefaultValue (DataGridViewHeaderBorderStyle.Raised)]
887 public DataGridViewHeaderBorderStyle RowHeadersBorderStyle {
888 get { return rowHeadersBorderStyle; }
890 if (rowHeadersBorderStyle != value) {
891 rowHeadersBorderStyle = value;
892 OnRowHeadersBorderStyleChanged(EventArgs.Empty);
897 [AmbientValue (null)]
898 public DataGridViewCellStyle RowHeadersDefaultCellStyle {
899 get { return rowHeadersDefaultCellStyle; }
901 if (rowHeadersDefaultCellStyle != value) {
902 rowHeadersDefaultCellStyle = value;
903 OnRowHeadersDefaultCellStyleChanged(EventArgs.Empty);
908 [DefaultValue (true)]
909 public bool RowHeadersVisible {
910 get { return rowHeadersVisible; }
911 set { rowHeadersVisible = value; }
915 public int RowHeadersWidth {
916 get { return rowHeadersWidth; }
918 if (rowHeadersWidth != value) {
920 throw new ArgumentOutOfRangeException("RowHeadersWidth",
921 "Row headers width cant be less than 4.");
923 if (value > 32768 ) {
924 throw new ArgumentOutOfRangeException("RowHeadersWidth",
925 "Row headers width cannot be more than 32768.");
927 rowHeadersWidth = value;
928 OnRowHeadersWidthChanged(EventArgs.Empty);
933 [RefreshProperties (RefreshProperties.All)]
934 [DefaultValue (DataGridViewRowHeadersWidthSizeMode.EnableResizing)]
935 public DataGridViewRowHeadersWidthSizeMode RowHeadersWidthSizeMode {
936 get { return rowHeadersWidthSizeMode; }
938 if (rowHeadersWidthSizeMode != value) {
939 if (!Enum.IsDefined(typeof(DataGridViewRowHeadersWidthSizeMode), value)) {
940 throw new InvalidEnumArgumentException("Value is not valid DataGridViewRowHeadersWidthSizeMode.");
942 rowHeadersWidthSizeMode = value;
943 OnRowHeadersWidthSizeModeChanged(new DataGridViewAutoSizeModeEventArgs(false));
949 public DataGridViewRowCollection Rows {
953 public DataGridViewCellStyle RowsDefaultCellStyle {
954 get { return rowsDefaultCellStyle; }
956 if (rowsDefaultCellStyle != value) {
957 rowsDefaultCellStyle = value;
958 OnRowsDefaultCellStyleChanged(EventArgs.Empty);
964 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
965 public DataGridViewRow RowTemplate {
967 if (rowTemplate == null) {
968 return new DataGridViewRow();
974 rowTemplate.SetDataGridView(this);
978 [DefaultValue (ScrollBars.Both)]
980 public ScrollBars ScrollBars {
981 get { return scrollBars; }
983 if (!Enum.IsDefined(typeof(ScrollBars), value)) {
984 throw new InvalidEnumArgumentException("Invalid ScrollBars value.");
986 ////////////////////////////////////////////////////////////
987 /// *** InvalidOperationException ***
988 /// The System.Windows.Forms.DataGridView is unable to
989 /// scroll due to a cell change that cannot be committed
991 ///////////////////////////////////////////////////////////
997 public DataGridViewSelectedCellCollection SelectedCells {
999 DataGridViewSelectedCellCollection selectedCells = new DataGridViewSelectedCellCollection();
1000 foreach (DataGridViewRow row in rows) {
1001 foreach (DataGridViewCell cell in row.Cells) {
1002 if (cell.Selected) {
1003 selectedCells.InternalAdd(cell);
1007 return selectedCells;
1012 public DataGridViewSelectedColumnCollection SelectedColumns {
1014 DataGridViewSelectedColumnCollection selectedColumns = new DataGridViewSelectedColumnCollection();
1015 if (selectionMode == DataGridViewSelectionMode.FullColumnSelect || selectionMode == DataGridViewSelectionMode.ColumnHeaderSelect) {
1016 foreach (DataGridViewColumn col in columns) {
1018 selectedColumns.InternalAdd(col);
1022 return selectedColumns;
1027 public DataGridViewSelectedRowCollection SelectedRows {
1029 DataGridViewSelectedRowCollection selectedRows = new DataGridViewSelectedRowCollection();
1030 if (selectionMode == DataGridViewSelectionMode.FullColumnSelect || selectionMode == DataGridViewSelectionMode.RowHeaderSelect) {
1031 foreach (DataGridViewRow row in rows) {
1033 selectedRows.InternalAdd(row);
1037 return selectedRows;
1042 [DefaultValue (DataGridViewSelectionMode.RowHeaderSelect)]
1043 public DataGridViewSelectionMode SelectionMode {
1044 get { return selectionMode; }
1046 if (!Enum.IsDefined(typeof(DataGridViewSelectionMode), value)) {
1047 throw new InvalidEnumArgumentException("Value is not valid DataGridViewSelectionMode.");
1049 selectionMode = value;
1053 [DefaultValue (true)]
1054 public bool ShowCellErrors {
1055 get { return showCellErrors; }
1056 set { showCellErrors = value; }
1059 [DefaultValue (true)]
1060 public bool ShowCellToolTips {
1061 get { return showCellToolTips; }
1062 set { showCellToolTips = value; }
1065 [DefaultValue (true)]
1066 public bool ShowEditingIcon {
1067 get { return showEditingIcon; }
1068 set { showEditingIcon = value; }
1071 [DefaultValue (true)]
1072 public bool ShowRowErrors {
1073 get { return showRowErrors; }
1074 set { showRowErrors = value; }
1078 public DataGridViewColumn SortedColumn {
1079 get { return sortedColumn; }
1083 public SortOrder SortOrder {
1084 get { return sortOrder; }
1087 [DefaultValue (false)]
1088 [EditorBrowsable (EditorBrowsableState.Advanced)]
1089 public bool StandardTab {
1090 get { return standardTab; }
1091 set { standardTab = value; }
1096 [EditorBrowsable (EditorBrowsableState.Never)]
1097 public override string Text {
1098 get { return base.Text; }
1099 set { base.Text = value; }
1103 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
1104 public DataGridViewHeaderCell TopLeftHeaderCell {
1105 get { return topLeftHeaderCell; }
1106 set { topLeftHeaderCell = value; }
1110 [EditorBrowsable (EditorBrowsableState.Advanced)]
1111 public Cursor UserSetCursor {
1112 get { return userSetCursor; }
1116 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
1117 public int VerticalScrollingOffset {
1118 get { return verticalScrollingOffset; }
1121 [EditorBrowsable (EditorBrowsableState.Advanced)]
1122 [DefaultValue (false)]
1123 public bool VirtualMode {
1124 get { return virtualMode; }
1125 set { virtualMode = value; }
1128 static object AllowUserToAddRowsChangedEvent = new object ();
1129 static object AllowUserToDeleteRowsChangedEvent = new object ();
1130 static object AllowUserToOrderColumnsChangedEvent = new object ();
1131 static object AllowUserToResizeColumnsChangedEvent = new object ();
1132 static object AllowUserToResizeRowsChangedEvent = new object ();
1133 static object AlternatingRowsDefaultCellStyleChangedEvent = new object ();
1134 static object AutoGenerateColumnsChangedEvent = new object ();
1135 static object AutoSizeColumnModeChangedEvent = new object ();
1136 static object AutoSizeColumnsModeChangedEvent = new object ();
1137 static object AutoSizeRowsModeChangedEvent = new object ();
1138 static object BackgroundColorChangedEvent = new object ();
1139 static object BorderStyleChangedEvent = new object ();
1140 static object CancelRowEditEvent = new object ();
1141 static object CellBeginEditEvent = new object ();
1142 static object CellBorderStyleChangedEvent = new object ();
1143 static object CellClickEvent = new object ();
1144 static object CellContentClickEvent = new object ();
1145 static object CellContentDoubleClickEvent = new object ();
1146 static object CellContextMenuStripChangedEvent = new object ();
1147 static object CellContextMenuStripNeededEvent = new object ();
1148 static object CellDoubleClickEvent = new object ();
1149 static object CellEndEditEvent = new object ();
1150 static object CellEnterEvent = new object ();
1151 static object CellErrorTextChangedEvent = new object ();
1152 static object CellErrorTextNeededEvent = new object ();
1153 static object CellFormattingEvent = new object ();
1154 static object CellLeaveEvent = new object ();
1155 static object CellMouseClickEvent = new object ();
1156 static object CellMouseDoubleClickEvent = new object ();
1157 static object CellMouseDownEvent = new object ();
1158 static object CellMouseEnterEvent = new object ();
1159 static object CellMouseLeaveEvent = new object ();
1160 static object CellMouseMoveEvent = new object ();
1161 static object CellMouseUpEvent = new object ();
1162 static object CellPaintingEvent = new object ();
1163 static object CellParsingEvent = new object ();
1164 static object CellStateChangedEvent = new object ();
1165 static object CellStyleChangedEvent = new object ();
1166 static object CellStyleContentChangedEvent = new object ();
1167 static object CellToolTipTextChangedEvent = new object ();
1168 static object CellToolTipTextNeededEvent = new object ();
1169 static object CellValidatedEvent = new object ();
1170 static object CellValidatingEvent = new object ();
1171 static object CellValueChangedEvent = new object ();
1172 static object CellValueNeededEvent = new object ();
1173 static object CellValuePushedEvent = new object ();
1174 static object ColumnAddedEvent = new object ();
1175 static object ColumnContextMenuStripChangedEvent = new object ();
1176 static object ColumnDataPropertyNameChangedEvent = new object ();
1177 static object ColumnDefaultCellStyleChangedEvent = new object ();
1178 static object ColumnDisplayIndexChangedEvent = new object ();
1179 static object ColumnDividerDoubleClickEvent = new object ();
1180 static object ColumnDividerWidthChangedEvent = new object ();
1181 static object ColumnHeaderCellChangedEvent = new object ();
1182 static object ColumnHeaderMouseClickEvent = new object ();
1183 static object ColumnHeaderMouseDoubleClickEvent = new object ();
1184 static object ColumnHeadersBorderStyleChangedEvent = new object ();
1185 static object ColumnHeadersDefaultCellStyleChangedEvent = new object ();
1186 static object ColumnHeadersHeightChangedEvent = new object ();
1187 static object ColumnHeadersHeightSizeModeChangedEvent = new object ();
1188 static object ColumnMinimumWidthChangedEvent = new object ();
1189 static object ColumnNameChangedEvent = new object ();
1190 static object ColumnRemovedEvent = new object ();
1191 static object ColumnSortModeChangedEvent = new object ();
1192 static object ColumnStateChangedEvent = new object ();
1193 static object ColumnToolTipTextChangedEvent = new object ();
1194 static object ColumnWidthChangedEvent = new object ();
1195 static object CurrentCellChangedEvent = new object ();
1196 static object CurrentCellDirtyStateChangedEvent = new object ();
1197 static object DataBindingCompleteEvent = new object ();
1198 static object DataErrorEvent = new object ();
1199 static object DataMemberChangedEvent = new object ();
1200 static object DataSourceChangedEvent = new object ();
1201 static object DefaultCellStyleChangedEvent = new object ();
1202 static object DefaultValuesNeededEvent = new object ();
1203 static object EditingControlShowingEvent = new object ();
1204 static object EditModeChangedEvent = new object ();
1205 static object GridColorChangedEvent = new object ();
1206 static object MultiSelectChangedEvent = new object ();
1207 static object NewRowNeededEvent = new object ();
1208 static object ReadOnlyChangedEvent = new object ();
1209 static object RowContextMenuStripChangedEvent = new object ();
1210 static object RowContextMenuStripNeededEvent = new object ();
1211 static object RowDefaultCellStyleChangedEvent = new object ();
1212 static object RowDirtyStateNeededEvent = new object ();
1213 static object RowDividerDoubleClickEvent = new object ();
1214 static object RowDividerHeightChangedEvent = new object ();
1215 static object RowEnterEvent = new object ();
1216 static object RowErrorTextChangedEvent = new object ();
1217 static object RowErrorTextNeededEvent = new object ();
1218 static object RowHeaderCellChangedEvent = new object ();
1219 static object RowHeaderMouseClickEvent = new object ();
1220 static object RowHeaderMouseDoubleClickEvent = new object ();
1221 static object RowHeadersBorderStyleChangedEvent = new object ();
1222 static object RowHeadersDefaultCellStyleChangedEvent = new object ();
1223 static object RowHeadersWidthChangedEvent = new object ();
1224 static object RowHeadersWidthSizeModeChangedEvent = new object ();
1225 static object RowHeightChangedEvent = new object ();
1226 static object RowHeightInfoNeededEvent = new object ();
1227 static object RowHeightInfoPushedEvent = new object ();
1228 static object RowLeaveEvent = new object ();
1229 static object RowMinimumHeightChangedEvent = new object ();
1230 static object RowPostPaintEvent = new object ();
1231 static object RowPrePaintEvent = new object ();
1232 static object RowsAddedEvent = new object ();
1233 static object RowsDefaultCellStyleChangedEvent = new object ();
1234 static object RowsRemovedEvent = new object ();
1235 static object RowStateChangedEvent = new object ();
1236 static object RowUnsharedEvent = new object ();
1237 static object RowValidatedEvent = new object ();
1238 static object RowValidatingEvent = new object ();
1239 static object ScrollEvent = new object ();
1240 static object SelectionChangedEvent = new object ();
1241 static object SortCompareEvent = new object ();
1242 static object SortedEvent = new object ();
1243 static object UserAddedRowEvent = new object ();
1244 static object UserDeletedRowEvent = new object ();
1245 static object UserDeletingRowEvent = new object ();
1250 public event EventHandler AllowUserToAddRowsChanged {
1251 add { Events.AddHandler (AllowUserToAddRowsChangedEvent, value); }
1252 remove { Events.RemoveHandler (AllowUserToAddRowsChangedEvent, value); }
1255 public event EventHandler AllowUserToDeleteRowsChanged {
1256 add { Events.AddHandler (AllowUserToDeleteRowsChangedEvent, value); }
1257 remove { Events.RemoveHandler (AllowUserToDeleteRowsChangedEvent, value); }
1260 public event EventHandler AllowUserToOrderColumnsChanged {
1261 add { Events.AddHandler (AllowUserToOrderColumnsChangedEvent, value); }
1262 remove { Events.RemoveHandler (AllowUserToOrderColumnsChangedEvent, value); }
1265 public event EventHandler AllowUserToResizeColumnsChanged {
1266 add { Events.AddHandler (AllowUserToResizeColumnsChangedEvent, value); }
1267 remove { Events.RemoveHandler (AllowUserToResizeColumnsChangedEvent, value); }
1270 public event EventHandler AllowUserToResizeRowsChanged {
1271 add { Events.AddHandler (AllowUserToResizeRowsChangedEvent, value); }
1272 remove { Events.RemoveHandler (AllowUserToResizeRowsChangedEvent, value); }
1275 public event EventHandler AlternatingRowsDefaultCellStyleChanged {
1276 add { Events.AddHandler (AlternatingRowsDefaultCellStyleChangedEvent, value); }
1277 remove { Events.RemoveHandler (AlternatingRowsDefaultCellStyleChangedEvent, value); }
1281 [EditorBrowsable (EditorBrowsableState.Advanced)]
1282 public event EventHandler AutoGenerateColumnsChanged {
1283 add { Events.AddHandler (AutoGenerateColumnsChangedEvent, value); }
1284 remove { Events.RemoveHandler (AutoGenerateColumnsChangedEvent, value); }
1287 public event DataGridViewAutoSizeColumnModeEventHandler AutoSizeColumnModeChanged {
1288 add { Events.AddHandler (AutoSizeColumnModeChangedEvent, value); }
1289 remove { Events.RemoveHandler (AutoSizeColumnModeChangedEvent, value); }
1292 public event DataGridViewAutoSizeColumnsModeEventHandler AutoSizeColumnsModeChanged {
1293 add { Events.AddHandler (AutoSizeColumnsModeChangedEvent, value); }
1294 remove { Events.RemoveHandler (AutoSizeColumnsModeChangedEvent, value); }
1297 public event DataGridViewAutoSizeModeEventHandler AutoSizeRowsModeChanged {
1298 add { Events.AddHandler (AutoSizeRowsModeChangedEvent, value); }
1299 remove { Events.RemoveHandler (AutoSizeRowsModeChangedEvent, value); }
1303 [EditorBrowsable (EditorBrowsableState.Never)]
1304 public new event EventHandler BackColorChanged {
1305 add { base.BackColorChanged += value; }
1306 remove { base.BackColorChanged -= value; }
1309 public event EventHandler BackgroundColorChanged {
1310 add { Events.AddHandler (BackgroundColorChangedEvent, value); }
1311 remove { Events.RemoveHandler (BackgroundColorChangedEvent, value); }
1315 [EditorBrowsable (EditorBrowsableState.Never)]
1316 public new event EventHandler BackgroundImageChanged {
1317 add { base.BackgroundImageChanged += value; }
1318 remove { base.BackgroundImageChanged -= value; }
1322 [EditorBrowsable (EditorBrowsableState.Never)]
1323 public new event EventHandler BackgroundImageLayoutChanged; /* XXX {
1324 add { base.BackgroundImageLayoutChanged += value; }
1325 remove { base.BackgroundImageLayoutChanged -= value; }
1328 public event EventHandler BorderStyleChanged {
1329 add { Events.AddHandler (BorderStyleChangedEvent, value); }
1330 remove { Events.RemoveHandler (BorderStyleChangedEvent, value); }
1333 public event QuestionEventHandler CancelRowEdit {
1334 add { Events.AddHandler (CancelRowEditEvent, value); }
1335 remove { Events.RemoveHandler (CancelRowEditEvent, value); }
1338 public event DataGridViewCellCancelEventHandler CellBeginEdit {
1339 add { Events.AddHandler (CellBeginEditEvent, value); }
1340 remove { Events.RemoveHandler (CellBeginEditEvent, value); }
1343 public event EventHandler CellBorderStyleChanged {
1344 add { Events.AddHandler (CellBorderStyleChangedEvent, value); }
1345 remove { Events.RemoveHandler (CellBorderStyleChangedEvent, value); }
1348 public event DataGridViewCellEventHandler CellClick {
1349 add { Events.AddHandler (CellClickEvent, value); }
1350 remove { Events.RemoveHandler (CellClickEvent, value); }
1353 public event DataGridViewCellEventHandler CellContentClick {
1354 add { Events.AddHandler (CellContentClickEvent, value); }
1355 remove { Events.RemoveHandler (CellContentClickEvent, value); }
1358 public event DataGridViewCellEventHandler CellContentDoubleClick {
1359 add { Events.AddHandler (CellContentDoubleClickEvent, value); }
1360 remove { Events.RemoveHandler (CellContentDoubleClickEvent, value); }
1363 [EditorBrowsable (EditorBrowsableState.Advanced)]
1364 public event DataGridViewCellEventHandler CellContextMenuStripChanged {
1365 add { Events.AddHandler (CellContextMenuStripChangedEvent, value); }
1366 remove { Events.RemoveHandler (CellContextMenuStripChangedEvent, value); }
1369 [EditorBrowsable (EditorBrowsableState.Advanced)]
1370 public event DataGridViewCellContextMenuStripNeededEventHandler CellContextMenuStripNeeded {
1371 add { Events.AddHandler (CellContextMenuStripNeededEvent, value); }
1372 remove { Events.RemoveHandler (CellContextMenuStripNeededEvent, value); }
1375 public event DataGridViewCellEventHandler CellDoubleClick {
1376 add { Events.AddHandler (CellDoubleClickEvent, value); }
1377 remove { Events.RemoveHandler (CellDoubleClickEvent, value); }
1380 public event DataGridViewCellEventHandler CellEndEdit {
1381 add { Events.AddHandler (CellEndEditEvent, value); }
1382 remove { Events.RemoveHandler (CellEndEditEvent, value); }
1385 public event DataGridViewCellEventHandler CellEnter {
1386 add { Events.AddHandler (CellEnterEvent, value); }
1387 remove { Events.RemoveHandler (CellEnterEvent, value); }
1390 public event DataGridViewCellEventHandler CellErrorTextChanged {
1391 add { Events.AddHandler (CellErrorTextChangedEvent, value); }
1392 remove { Events.RemoveHandler (CellErrorTextChangedEvent, value); }
1395 [EditorBrowsable (EditorBrowsableState.Advanced)]
1396 public event DataGridViewCellErrorTextNeededEventHandler CellErrorTextNeeded {
1397 add { Events.AddHandler (CellErrorTextNeededEvent, value); }
1398 remove { Events.RemoveHandler (CellErrorTextNeededEvent, value); }
1401 public event DataGridViewCellFormattingEventHandler CellFormatting {
1402 add { Events.AddHandler (CellFormattingEvent, value); }
1403 remove { Events.RemoveHandler (CellFormattingEvent, value); }
1406 public event DataGridViewCellEventHandler CellLeave {
1407 add { Events.AddHandler (CellLeaveEvent, value); }
1408 remove { Events.RemoveHandler (CellLeaveEvent, value); }
1411 public event DataGridViewCellMouseEventHandler CellMouseClick {
1412 add { Events.AddHandler (CellMouseClickEvent, value); }
1413 remove { Events.RemoveHandler (CellMouseClickEvent, value); }
1416 public event DataGridViewCellMouseEventHandler CellMouseDoubleClick {
1417 add { Events.AddHandler (CellMouseDoubleClickEvent, value); }
1418 remove { Events.RemoveHandler (CellMouseDoubleClickEvent, value); }
1421 public event DataGridViewCellMouseEventHandler CellMouseDown {
1422 add { Events.AddHandler (CellMouseDownEvent, value); }
1423 remove { Events.RemoveHandler (CellMouseDownEvent, value); }
1426 public event DataGridViewCellEventHandler CellMouseEnter {
1427 add { Events.AddHandler (CellMouseEnterEvent, value); }
1428 remove { Events.RemoveHandler (CellMouseEnterEvent, value); }
1431 public event DataGridViewCellEventHandler CellMouseLeave {
1432 add { Events.AddHandler (CellMouseLeaveEvent, value); }
1433 remove { Events.RemoveHandler (CellMouseLeaveEvent, value); }
1436 public event DataGridViewCellMouseEventHandler CellMouseMove {
1437 add { Events.AddHandler (CellMouseMoveEvent, value); }
1438 remove { Events.RemoveHandler (CellMouseMoveEvent, value); }
1441 public event DataGridViewCellMouseEventHandler CellMouseUp {
1442 add { Events.AddHandler (CellMouseUpEvent, value); }
1443 remove { Events.RemoveHandler (CellMouseUpEvent, value); }
1446 public event DataGridViewCellPaintingEventHandler CellPainting {
1447 add { Events.AddHandler (CellPaintingEvent, value); }
1448 remove { Events.RemoveHandler (CellPaintingEvent, value); }
1451 public event DataGridViewCellParsingEventHandler CellParsing {
1452 add { Events.AddHandler (CellParsingEvent, value); }
1453 remove { Events.RemoveHandler (CellParsingEvent, value); }
1456 public event DataGridViewCellStateChangedEventHandler CellStateChanged {
1457 add { Events.AddHandler (CellStateChangedEvent, value); }
1458 remove { Events.RemoveHandler (CellStateChangedEvent, value); }
1461 public event DataGridViewCellEventHandler CellStyleChanged {
1462 add { Events.AddHandler (CellStyleChangedEvent, value); }
1463 remove { Events.RemoveHandler (CellStyleChangedEvent, value); }
1466 public event DataGridViewCellStyleContentChangedEventHandler CellStyleContentChanged {
1467 add { Events.AddHandler (CellStyleContentChangedEvent, value); }
1468 remove { Events.RemoveHandler (CellStyleContentChangedEvent, value); }
1471 public event DataGridViewCellEventHandler CellToolTipTextChanged {
1472 add { Events.AddHandler (CellToolTipTextChangedEvent, value); }
1473 remove { Events.RemoveHandler (CellToolTipTextChangedEvent, value); }
1476 [EditorBrowsable (EditorBrowsableState.Advanced)]
1477 public event DataGridViewCellToolTipTextNeededEventHandler CellToolTipTextNeeded {
1478 add { Events.AddHandler (CellToolTipTextNeededEvent, value); }
1479 remove { Events.RemoveHandler (CellToolTipTextNeededEvent, value); }
1482 public event DataGridViewCellEventHandler CellValidated {
1483 add { Events.AddHandler (CellValidatedEvent, value); }
1484 remove { Events.RemoveHandler (CellValidatedEvent, value); }
1487 public event DataGridViewCellValidatingEventHandler CellValidating {
1488 add { Events.AddHandler (CellValidatingEvent, value); }
1489 remove { Events.RemoveHandler (CellValidatingEvent, value); }
1492 public event DataGridViewCellEventHandler CellValueChanged {
1493 add { Events.AddHandler (CellValueChangedEvent, value); }
1494 remove { Events.RemoveHandler (CellValueChangedEvent, value); }
1497 [EditorBrowsable (EditorBrowsableState.Advanced)]
1498 public event DataGridViewCellValueEventHandler CellValueNeeded {
1499 add { Events.AddHandler (CellValueNeededEvent, value); }
1500 remove { Events.RemoveHandler (CellValueNeededEvent, value); }
1503 [EditorBrowsable (EditorBrowsableState.Advanced)]
1504 public event DataGridViewCellValueEventHandler CellValuePushed {
1505 add { Events.AddHandler (CellValuePushedEvent, value); }
1506 remove { Events.RemoveHandler (CellValuePushedEvent, value); }
1509 public event DataGridViewColumnEventHandler ColumnAdded {
1510 add { Events.AddHandler (ColumnAddedEvent, value); }
1511 remove { Events.RemoveHandler (ColumnAddedEvent, value); }
1514 public event DataGridViewColumnEventHandler ColumnContextMenuStripChanged {
1515 add { Events.AddHandler (ColumnContextMenuStripChangedEvent, value); }
1516 remove { Events.RemoveHandler (ColumnContextMenuStripChangedEvent, value); }
1519 public event DataGridViewColumnEventHandler ColumnDataPropertyNameChanged {
1520 add { Events.AddHandler (ColumnDataPropertyNameChangedEvent, value); }
1521 remove { Events.RemoveHandler (ColumnDataPropertyNameChangedEvent, value); }
1524 public event DataGridViewColumnEventHandler ColumnDefaultCellStyleChanged {
1525 add { Events.AddHandler (ColumnDefaultCellStyleChangedEvent, value); }
1526 remove { Events.RemoveHandler (ColumnDefaultCellStyleChangedEvent, value); }
1529 public event DataGridViewColumnEventHandler ColumnDisplayIndexChanged {
1530 add { Events.AddHandler (ColumnDisplayIndexChangedEvent, value); }
1531 remove { Events.RemoveHandler (ColumnDisplayIndexChangedEvent, value); }
1534 public event DataGridViewColumnDividerDoubleClickEventHandler ColumnDividerDoubleClick {
1535 add { Events.AddHandler (ColumnDividerDoubleClickEvent, value); }
1536 remove { Events.RemoveHandler (ColumnDividerDoubleClickEvent, value); }
1539 public event DataGridViewColumnEventHandler ColumnDividerWidthChanged {
1540 add { Events.AddHandler (ColumnDividerWidthChangedEvent, value); }
1541 remove { Events.RemoveHandler (ColumnDividerWidthChangedEvent, value); }
1544 public event DataGridViewColumnEventHandler ColumnHeaderCellChanged {
1545 add { Events.AddHandler (ColumnHeaderCellChangedEvent, value); }
1546 remove { Events.RemoveHandler (ColumnHeaderCellChangedEvent, value); }
1549 public event DataGridViewCellMouseEventHandler ColumnHeaderMouseClick {
1550 add { Events.AddHandler (ColumnHeaderMouseClickEvent, value); }
1551 remove { Events.RemoveHandler (ColumnHeaderMouseClickEvent, value); }
1554 public event DataGridViewCellMouseEventHandler ColumnHeaderMouseDoubleClick {
1555 add { Events.AddHandler (ColumnHeaderMouseDoubleClickEvent, value); }
1556 remove { Events.RemoveHandler (ColumnHeaderMouseDoubleClickEvent, value); }
1559 public event EventHandler ColumnHeadersBorderStyleChanged {
1560 add { Events.AddHandler (ColumnHeadersBorderStyleChangedEvent, value); }
1561 remove { Events.RemoveHandler (ColumnHeadersBorderStyleChangedEvent, value); }
1564 public event EventHandler ColumnHeadersDefaultCellStyleChanged {
1565 add { Events.AddHandler (ColumnHeadersDefaultCellStyleChangedEvent, value); }
1566 remove { Events.RemoveHandler (ColumnHeadersDefaultCellStyleChangedEvent, value); }
1569 public event EventHandler ColumnHeadersHeightChanged {
1570 add { Events.AddHandler (ColumnHeadersHeightChangedEvent, value); }
1571 remove { Events.RemoveHandler (ColumnHeadersHeightChangedEvent, value); }
1574 public event DataGridViewAutoSizeModeEventHandler ColumnHeadersHeightSizeModeChanged {
1575 add { Events.AddHandler (ColumnHeadersHeightSizeModeChangedEvent, value); }
1576 remove { Events.RemoveHandler (ColumnHeadersHeightSizeModeChangedEvent, value); }
1579 public event DataGridViewColumnEventHandler ColumnMinimumWidthChanged {
1580 add { Events.AddHandler (ColumnMinimumWidthChangedEvent, value); }
1581 remove { Events.RemoveHandler (ColumnMinimumWidthChangedEvent, value); }
1584 public event DataGridViewColumnEventHandler ColumnNameChanged {
1585 add { Events.AddHandler (ColumnNameChangedEvent, value); }
1586 remove { Events.RemoveHandler (ColumnNameChangedEvent, value); }
1589 public event DataGridViewColumnEventHandler ColumnRemoved {
1590 add { Events.AddHandler (ColumnRemovedEvent, value); }
1591 remove { Events.RemoveHandler (ColumnRemovedEvent, value); }
1594 public event DataGridViewColumnEventHandler ColumnSortModeChanged {
1595 add { Events.AddHandler (ColumnSortModeChangedEvent, value); }
1596 remove { Events.RemoveHandler (ColumnSortModeChangedEvent, value); }
1599 public event DataGridViewColumnStateChangedEventHandler ColumnStateChanged {
1600 add { Events.AddHandler (ColumnStateChangedEvent, value); }
1601 remove { Events.RemoveHandler (ColumnStateChangedEvent, value); }
1604 public event DataGridViewColumnEventHandler ColumnToolTipTextChanged {
1605 add { Events.AddHandler (ColumnToolTipTextChangedEvent, value); }
1606 remove { Events.RemoveHandler (ColumnToolTipTextChangedEvent, value); }
1609 public event DataGridViewColumnEventHandler ColumnWidthChanged {
1610 add { Events.AddHandler (ColumnWidthChangedEvent, value); }
1611 remove { Events.RemoveHandler (ColumnWidthChangedEvent, value); }
1614 public event EventHandler CurrentCellChanged {
1615 add { Events.AddHandler (CurrentCellChangedEvent, value); }
1616 remove { Events.RemoveHandler (CurrentCellChangedEvent, value); }
1619 [EditorBrowsable (EditorBrowsableState.Advanced)]
1620 public event EventHandler CurrentCellDirtyStateChanged {
1621 add { Events.AddHandler (CurrentCellDirtyStateChangedEvent, value); }
1622 remove { Events.RemoveHandler (CurrentCellDirtyStateChangedEvent, value); }
1625 public event DataGridViewBindingCompleteEventHandler DataBindingComplete {
1626 add { Events.AddHandler (DataBindingCompleteEvent, value); }
1627 remove { Events.RemoveHandler (DataBindingCompleteEvent, value); }
1630 public event DataGridViewDataErrorEventHandler DataError {
1631 add { Events.AddHandler (DataErrorEvent, value); }
1632 remove { Events.RemoveHandler (DataErrorEvent, value); }
1635 public event EventHandler DataMemberChanged {
1636 add { Events.AddHandler (DataMemberChangedEvent, value); }
1637 remove { Events.RemoveHandler (DataMemberChangedEvent, value); }
1640 public event EventHandler DataSourceChanged {
1641 add { Events.AddHandler (DataSourceChangedEvent, value); }
1642 remove { Events.RemoveHandler (DataSourceChangedEvent, value); }
1645 public event EventHandler DefaultCellStyleChanged {
1646 add { Events.AddHandler (DefaultCellStyleChangedEvent, value); }
1647 remove { Events.RemoveHandler (DefaultCellStyleChangedEvent, value); }
1650 [EditorBrowsable (EditorBrowsableState.Advanced)]
1651 public event DataGridViewRowEventHandler DefaultValuesNeeded {
1652 add { Events.AddHandler (DefaultValuesNeededEvent, value); }
1653 remove { Events.RemoveHandler (DefaultValuesNeededEvent, value); }
1656 public event DataGridViewEditingControlShowingEventHandler EditingControlShowing {
1657 add { Events.AddHandler (EditingControlShowingEvent, value); }
1658 remove { Events.RemoveHandler (EditingControlShowingEvent, value); }
1661 public event EventHandler EditModeChanged {
1662 add { Events.AddHandler (EditModeChangedEvent, value); }
1663 remove { Events.RemoveHandler (EditModeChangedEvent, value); }
1667 [EditorBrowsable (EditorBrowsableState.Advanced)]
1668 public new event EventHandler FontChanged {
1669 add { base.FontChanged += value; }
1670 remove { base.FontChanged -= value; }
1674 [EditorBrowsable (EditorBrowsableState.Advanced)]
1675 public new event EventHandler ForeColorChanged {
1676 add { base.ForeColorChanged += value; }
1677 remove { base.ForeColorChanged -= value; }
1681 [EditorBrowsable (EditorBrowsableState.Never)]
1682 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
1683 public new event EventHandler PaddingChanged {
1684 add { base.PaddingChanged += value; }
1685 remove { base.PaddingChanged -= value; }
1688 public event EventHandler GridColorChanged {
1689 add { Events.AddHandler (GridColorChangedEvent, value); }
1690 remove { Events.RemoveHandler (GridColorChangedEvent, value); }
1693 public event EventHandler MultiSelectChanged {
1694 add { Events.AddHandler (MultiSelectChangedEvent, value); }
1695 remove { Events.RemoveHandler (MultiSelectChangedEvent, value); }
1698 public event DataGridViewRowEventHandler NewRowNeeded {
1699 add { Events.AddHandler (NewRowNeededEvent, value); }
1700 remove { Events.RemoveHandler (NewRowNeededEvent, value); }
1703 public event EventHandler ReadOnlyChanged {
1704 add { Events.AddHandler (ReadOnlyChangedEvent, value); }
1705 remove { Events.RemoveHandler (ReadOnlyChangedEvent, value); }
1708 public event DataGridViewRowEventHandler RowContextMenuStripChanged {
1709 add { Events.AddHandler (RowContextMenuStripChangedEvent, value); }
1710 remove { Events.RemoveHandler (RowContextMenuStripChangedEvent, value); }
1713 [EditorBrowsable (EditorBrowsableState.Advanced)]
1714 public event DataGridViewRowContextMenuStripNeededEventHandler RowContextMenuStripNeeded {
1715 add { Events.AddHandler (RowContextMenuStripNeededEvent, value); }
1716 remove { Events.RemoveHandler (RowContextMenuStripNeededEvent, value); }
1719 public event DataGridViewRowEventHandler RowDefaultCellStyleChanged {
1720 add { Events.AddHandler (RowDefaultCellStyleChangedEvent, value); }
1721 remove { Events.RemoveHandler (RowDefaultCellStyleChangedEvent, value); }
1724 [EditorBrowsable (EditorBrowsableState.Advanced)]
1725 public event QuestionEventHandler RowDirtyStateNeeded {
1726 add { Events.AddHandler (RowDirtyStateNeededEvent, value); }
1727 remove { Events.RemoveHandler (RowDirtyStateNeededEvent, value); }
1730 public event DataGridViewRowDividerDoubleClickEventHandler RowDividerDoubleClick {
1731 add { Events.AddHandler (RowDividerDoubleClickEvent, value); }
1732 remove { Events.RemoveHandler (RowDividerDoubleClickEvent, value); }
1735 public event DataGridViewRowEventHandler RowDividerHeightChanged {
1736 add { Events.AddHandler (RowDividerHeightChangedEvent, value); }
1737 remove { Events.RemoveHandler (RowDividerHeightChangedEvent, value); }
1740 public event DataGridViewCellEventHandler RowEnter {
1741 add { Events.AddHandler (RowEnterEvent, value); }
1742 remove { Events.RemoveHandler (RowEnterEvent, value); }
1745 public event DataGridViewRowEventHandler RowErrorTextChanged {
1746 add { Events.AddHandler (RowErrorTextChangedEvent, value); }
1747 remove { Events.RemoveHandler (RowErrorTextChangedEvent, value); }
1750 [EditorBrowsable (EditorBrowsableState.Advanced)]
1751 public event DataGridViewRowErrorTextNeededEventHandler RowErrorTextNeeded {
1752 add { Events.AddHandler (RowErrorTextNeededEvent, value); }
1753 remove { Events.RemoveHandler (RowErrorTextNeededEvent, value); }
1756 public event DataGridViewRowEventHandler RowHeaderCellChanged {
1757 add { Events.AddHandler (RowHeaderCellChangedEvent, value); }
1758 remove { Events.RemoveHandler (RowHeaderCellChangedEvent, value); }
1761 public event DataGridViewCellMouseEventHandler RowHeaderMouseClick {
1762 add { Events.AddHandler (RowHeaderMouseClickEvent, value); }
1763 remove { Events.RemoveHandler (RowHeaderMouseClickEvent, value); }
1766 public event DataGridViewCellMouseEventHandler RowHeaderMouseDoubleClick {
1767 add { Events.AddHandler (RowHeaderMouseDoubleClickEvent, value); }
1768 remove { Events.RemoveHandler (RowHeaderMouseDoubleClickEvent, value); }
1771 public event EventHandler RowHeadersBorderStyleChanged {
1772 add { Events.AddHandler (RowHeadersBorderStyleChangedEvent, value); }
1773 remove { Events.RemoveHandler (RowHeadersBorderStyleChangedEvent, value); }
1776 public event EventHandler RowHeadersDefaultCellStyleChanged {
1777 add { Events.AddHandler (RowHeadersDefaultCellStyleChangedEvent, value); }
1778 remove { Events.RemoveHandler (RowHeadersDefaultCellStyleChangedEvent, value); }
1781 public event EventHandler RowHeadersWidthChanged {
1782 add { Events.AddHandler (RowHeadersWidthChangedEvent, value); }
1783 remove { Events.RemoveHandler (RowHeadersWidthChangedEvent, value); }
1786 public event DataGridViewAutoSizeModeEventHandler RowHeadersWidthSizeModeChanged {
1787 add { Events.AddHandler (RowHeadersWidthSizeModeChangedEvent, value); }
1788 remove { Events.RemoveHandler (RowHeadersWidthSizeModeChangedEvent, value); }
1791 public event DataGridViewRowEventHandler RowHeightChanged {
1792 add { Events.AddHandler (RowHeightChangedEvent, value); }
1793 remove { Events.RemoveHandler (RowHeightChangedEvent, value); }
1796 [EditorBrowsable (EditorBrowsableState.Advanced)]
1797 public event DataGridViewRowHeightInfoNeededEventHandler RowHeightInfoNeeded {
1798 add { Events.AddHandler (RowHeightInfoNeededEvent, value); }
1799 remove { Events.RemoveHandler (RowHeightInfoNeededEvent, value); }
1802 [EditorBrowsable (EditorBrowsableState.Advanced)]
1803 public event DataGridViewRowHeightInfoPushedEventHandler RowHeightInfoPushed {
1804 add { Events.AddHandler (RowHeightInfoPushedEvent, value); }
1805 remove { Events.RemoveHandler (RowHeightInfoPushedEvent, value); }
1808 public event DataGridViewCellEventHandler RowLeave {
1809 add { Events.AddHandler (RowLeaveEvent, value); }
1810 remove { Events.RemoveHandler (RowLeaveEvent, value); }
1813 public event DataGridViewRowEventHandler RowMinimumHeightChanged {
1814 add { Events.AddHandler (RowMinimumHeightChangedEvent, value); }
1815 remove { Events.RemoveHandler (RowMinimumHeightChangedEvent, value); }
1818 public event DataGridViewRowPostPaintEventHandler RowPostPaint {
1819 add { Events.AddHandler (RowPostPaintEvent, value); }
1820 remove { Events.RemoveHandler (RowPostPaintEvent, value); }
1823 public event DataGridViewRowPrePaintEventHandler RowPrePaint {
1824 add { Events.AddHandler (RowPrePaintEvent, value); }
1825 remove { Events.RemoveHandler (RowPrePaintEvent, value); }
1828 public event DataGridViewRowsAddedEventHandler RowsAdded {
1829 add { Events.AddHandler (RowsAddedEvent, value); }
1830 remove { Events.RemoveHandler (RowsAddedEvent, value); }
1833 public event EventHandler RowsDefaultCellStyleChanged {
1834 add { Events.AddHandler (RowsDefaultCellStyleChangedEvent, value); }
1835 remove { Events.RemoveHandler (RowsDefaultCellStyleChangedEvent, value); }
1838 public event DataGridViewRowsRemovedEventHandler RowsRemoved {
1839 add { Events.AddHandler (RowsRemovedEvent, value); }
1840 remove { Events.RemoveHandler (RowsRemovedEvent, value); }
1843 public event DataGridViewRowStateChangedEventHandler RowStateChanged {
1844 add { Events.AddHandler (RowStateChangedEvent, value); }
1845 remove { Events.RemoveHandler (RowStateChangedEvent, value); }
1848 [EditorBrowsable (EditorBrowsableState.Advanced)]
1849 public event DataGridViewRowEventHandler RowUnshared {
1850 add { Events.AddHandler (RowUnsharedEvent, value); }
1851 remove { Events.RemoveHandler (RowUnsharedEvent, value); }
1854 public event DataGridViewCellEventHandler RowValidated {
1855 add { Events.AddHandler (RowValidatedEvent, value); }
1856 remove { Events.RemoveHandler (RowValidatedEvent, value); }
1859 public event DataGridViewCellCancelEventHandler RowValidating {
1860 add { Events.AddHandler (RowValidatingEvent, value); }
1861 remove { Events.RemoveHandler (RowValidatingEvent, value); }
1864 public event ScrollEventHandler Scroll {
1865 add { Events.AddHandler (ScrollEvent, value); }
1866 remove { Events.RemoveHandler (ScrollEvent, value); }
1869 public event EventHandler SelectionChanged {
1870 add { Events.AddHandler (SelectionChangedEvent, value); }
1871 remove { Events.RemoveHandler (SelectionChangedEvent, value); }
1874 [EditorBrowsable (EditorBrowsableState.Advanced)]
1875 public event DataGridViewSortCompareEventHandler SortCompare {
1876 add { Events.AddHandler (SortCompareEvent, value); }
1877 remove { Events.RemoveHandler (SortCompareEvent, value); }
1880 public event EventHandler Sorted {
1881 add { Events.AddHandler (SortedEvent, value); }
1882 remove { Events.RemoveHandler (SortedEvent, value); }
1885 public event DataGridViewRowEventHandler UserAddedRow {
1886 add { Events.AddHandler (UserAddedRowEvent, value); }
1887 remove { Events.RemoveHandler (UserAddedRowEvent, value); }
1890 public event DataGridViewRowEventHandler UserDeletedRow {
1891 add { Events.AddHandler (UserDeletedRowEvent, value); }
1892 remove { Events.RemoveHandler (UserDeletedRowEvent, value); }
1895 public event DataGridViewRowCancelEventHandler UserDeletingRow {
1896 add { Events.AddHandler (UserDeletingRowEvent, value); }
1897 remove { Events.RemoveHandler (UserDeletingRowEvent, value); }
1901 [EditorBrowsable (EditorBrowsableState.Never)]
1902 public new event EventHandler StyleChanged {
1903 add { base.StyleChanged += value; }
1904 remove { base.StyleChanged -= value; }
1908 [EditorBrowsable (EditorBrowsableState.Never)]
1909 public new event EventHandler TextChanged {
1910 add { base.TextChanged += value; }
1911 remove { base.TextChanged -= value; }
1914 [EditorBrowsable (EditorBrowsableState.Advanced)]
1915 public virtual DataGridViewAdvancedBorderStyle AdjustColumnHeaderBorderStyle (DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStyleInput, DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder, bool isFirstDisplayedColumn, bool isLastVisibleColumn) {
1916 return (DataGridViewAdvancedBorderStyle) ((ICloneable)dataGridViewAdvancedBorderStyleInput).Clone();
1919 public bool AreAllCellsSelected (bool includeInvisibleCells) {
1920 foreach (DataGridViewRow row in rows) {
1921 foreach (DataGridViewCell cell in row.Cells) {
1922 if (includeInvisibleCells == false && cell.Visible == false) {
1925 if (!cell.Selected) {
1933 public void AutoResizeColumn (int columnIndex) {
1934 throw new NotImplementedException();
1937 public void AutoResizeColumn (int columnIndex, DataGridViewAutoSizeColumnMode autoSizeColumnMode) {
1938 throw new NotImplementedException();
1941 public void AutoResizeColumnHeadersHeight () {
1942 throw new NotImplementedException();
1945 public void AutoResizeColumnHeadersHeight (int columnIndex) {
1946 throw new NotImplementedException();
1949 public void AutoResizeColumns () {
1950 throw new NotImplementedException();
1953 public void AutoResizeColumns (DataGridViewAutoSizeColumnsMode autoSizeColumnsMode) {
1954 throw new NotImplementedException();
1957 public void AutoResizeRow (int rowIndex) {
1958 throw new NotImplementedException();
1961 public void AutoResizeRow (int rowIndex, DataGridViewAutoSizeRowMode autoSizeRowMode) {
1962 throw new NotImplementedException();
1965 public void AutoResizeRowHeadersWidth (DataGridViewRowHeadersWidthSizeMode rowHeadersWidthSizeMode) {
1966 throw new NotImplementedException();
1969 public void AutoResizeRowHeadersWidth (int rowIndex, DataGridViewRowHeadersWidthSizeMode rowHeadersWidthSizeMode) {
1970 throw new NotImplementedException();
1973 public void AutoResizeRows () {
1974 throw new NotImplementedException();
1977 public void AutoResizeRows (DataGridViewAutoSizeRowsMode autoSizeRowsMode) {
1978 if (!Enum.IsDefined(typeof(DataGridViewAutoSizeRowsMode), autoSizeRowsMode)) {
1979 throw new InvalidEnumArgumentException("Parameter AutoSizeRowsMode is not valid DataGridViewRowsMode.");
1981 if ((autoSizeRowsMode == DataGridViewAutoSizeRowsMode.AllHeaders || autoSizeRowsMode == DataGridViewAutoSizeRowsMode.DisplayedHeaders) && rowHeadersVisible == false) {
1982 throw new InvalidOperationException("Parameter AutoSizeRowsMode cant be AllHeaders or DisplayedHeaders in this DataGridView.");
1984 if (autoSizeRowsMode == DataGridViewAutoSizeRowsMode.None) {
1985 throw new ArgumentException("Parameter AutoSieRowsMode cant be None.");
1989 public virtual bool BeginEdit (bool selectAll) {
1990 throw new NotImplementedException();
1993 public bool CancelEdit () {
1994 throw new NotImplementedException();
1997 public void ClearSelection () {
1998 foreach (DataGridViewCell cell in SelectedCells) {
1999 cell.Selected = false;
2003 public bool CommitEdit (DataGridViewDataErrorContexts context) {
2004 throw new NotImplementedException();
2007 public int DisplayedColumnCount (bool includePartialColumns) {
2008 /////////////////////// PartialColumns?
2010 foreach (DataGridViewColumn col in columns) {
2018 public int DisplayedRowCount (bool includePartialRow) {
2019 /////////////////////// PartialRows?
2021 foreach (DataGridViewRow row in rows) {
2029 public bool EndEdit () {
2030 throw new NotImplementedException();
2033 public bool EndEdit (DataGridViewDataErrorContexts context) {
2034 throw new NotImplementedException();
2037 public int GetCellCount (DataGridViewElementStates includeFilter) {
2039 foreach (DataGridViewRow row in rows) {
2040 foreach (DataGridViewCell cell in row.Cells) {
2041 if ((cell.State & includeFilter) != 0) {
2049 public Rectangle GetCellDisplayRectangle (int columnIndex, int rowIndex, bool cutOverflow) {
2050 if (columnIndex < 0 || columnIndex >= columns.Count) {
2051 throw new ArgumentOutOfRangeException("Column index is out of range.");
2053 throw new NotImplementedException();
2056 public virtual DataObject GetClipboardContent () {
2057 throw new NotImplementedException();
2060 public Rectangle GetColumnDisplayRectangle (int columnIndex, bool cutOverflow) {
2061 throw new NotImplementedException();
2064 public Rectangle GetRowDisplayRectangle (int rowIndex, bool cutOverflow) {
2065 throw new NotImplementedException();
2068 public HitTestInfo HitTest (int x, int y) {
2069 ///////////////////////////////////////////////////////
2070 x += horizontalScrollingOffset;
2071 y += verticalScrollingOffset;
2073 int totalHeight = (columnHeadersVisible)? 1 + columnHeadersHeight : 1;
2074 if (columnHeadersVisible && y <= totalHeight) {
2078 foreach (DataGridViewRow row in rows.RowIndexSortedArrayList) {
2079 totalHeight += row.Height;
2080 if (y <= totalHeight) {
2081 rowIndex = row.Index;
2084 totalHeight++; // sumar el ancho de las lineas...
2088 int totalWidth = (rowHeadersVisible)? 1 + rowHeadersWidth : 1;
2089 if (rowHeadersVisible && x <= totalWidth) {
2093 foreach (DataGridViewColumn col in columns.ColumnDisplayIndexSortedArrayList) {
2094 totalWidth += col.Width;
2095 if (x <= totalWidth) {
2096 colIndex = col.Index;
2102 HitTestInfo result = new HitTestInfo(colIndex, x, rowIndex, y, (colIndex >= 0 && rowIndex >= 0)? DataGridViewHitTestType.Cell : DataGridViewHitTestType.None);
2106 public void InvalidateCell (DataGridViewCell dataGridViewCell) {
2107 if (dataGridViewCell == null) {
2108 throw new ArgumentNullException("Cell is null");
2110 if (dataGridViewCell.DataGridView != this) {
2111 throw new ArgumentException("The specified cell does not belong to this DataGridView.");
2113 throw new NotImplementedException();
2116 public void InvalidateCell (int columnIndex, int rowIndex) {
2117 if (columnIndex < 0 || columnIndex >= columns.Count) {
2118 throw new ArgumentOutOfRangeException("Column index is out of range.");
2120 if (rowIndex < 0 || rowIndex >= rows.Count) {
2121 throw new ArgumentOutOfRangeException("Row index is out of range.");
2123 foreach (DataGridViewRow row in rows) {
2124 foreach (DataGridViewCell cell in row.Cells) {
2125 if (cell.RowIndex == rowIndex && cell.ColumnIndex == columnIndex) {
2126 InvalidateCell(cell); //// O al revés, que el otro llame a este !!!
2133 public void InvalidateColumn (int columnIndex) {
2134 if (columnIndex < 0 || columnIndex >= columns.Count) {
2135 throw new ArgumentOutOfRangeException("Column index is out of range.");
2137 throw new NotImplementedException();
2140 public void InvalidateRow (int rowIndex) {
2141 if (rowIndex < 0 || rowIndex >= rows.Count) {
2142 throw new ArgumentOutOfRangeException("Row index is out of range.");
2144 throw new NotImplementedException();
2147 public virtual void NotifyCurrentCellDirty (bool dirty) {
2148 throw new NotImplementedException();
2151 public bool RefreshEdit () {
2152 throw new NotImplementedException();
2155 [EditorBrowsable (EditorBrowsableState.Never)]
2156 public override void ResetText () {
2157 throw new NotImplementedException();
2160 public void SelectAll () {
2161 switch (selectionMode) {
2162 case DataGridViewSelectionMode.FullRowSelect:
2163 foreach (DataGridViewRow row in rows) {
2164 (row as DataGridViewBand).Selected = true;
2167 case DataGridViewSelectionMode.FullColumnSelect:
2168 foreach (DataGridViewColumn col in columns) {
2169 (col as DataGridViewBand).Selected = true;
2173 foreach (DataGridViewRow row in rows) {
2174 foreach (DataGridViewCell cell in row.Cells) {
2175 cell.Selected = true;
2182 public virtual void Sort (IComparer comparer) {
2183 throw new NotImplementedException();
2186 public virtual void Sort (DataGridViewColumn dataGridViewColumn, ListSortDirection direction) {
2187 throw new NotImplementedException();
2190 public void UpdateCellErrorText (int columnIndex, int rowIndex)
2192 throw new NotImplementedException();
2195 public void UpdateCellValue (int columnIndex, int rowIndex)
2197 throw new NotImplementedException();
2200 public void UpdateRowErrorText (int rowIndex)
2202 throw new NotImplementedException();
2205 public void UpdateRowErrorText (int rowIndexStart, int rowIndexEnd) {
2206 throw new NotImplementedException();
2209 public void UpdateRowHeightInfo (int rowIndex, bool updateToEnd) {
2210 throw new NotImplementedException();
2213 protected override Size DefaultSize {
2214 get { return new Size (240, 150); }
2217 protected ScrollBar HorizontalScrollBar {
2218 get { return horizontalScrollBar; }
2221 protected ScrollBar VerticalScrollBar {
2222 get { return verticalScrollBar; }
2225 protected virtual void AccessibilityNotifyCurrentCellChanged (Point cellAddress)
2227 throw new NotImplementedException ();
2230 protected void AutoResizeColumn (int columnIndex, DataGridViewAutoSizeColumnMode autoSizeColumnMode, bool fixedHeight) {
2231 throw new NotImplementedException();
2234 protected void AutoResizeColumnHeadersHeight (bool fixedRowHeadersWidth, bool fixedColumnsWidth) {
2235 throw new NotImplementedException();
2238 protected void AutoResizeColumnHeadersHeight (int columnIndex, bool fixedRowHeadersWidth, bool fixedColumnWidth) {
2239 throw new NotImplementedException();
2242 protected void AutoResizeColumns (DataGridViewAutoSizeColumnsMode autoSizeColumnsMode, bool fixedHeight) {
2243 throw new NotImplementedException();
2246 protected void AutoResizeRow (int rowIndex, DataGridViewAutoSizeRowMode autoSizeRowMode, bool fixedWidth) {
2247 throw new NotImplementedException();
2250 protected void AutoResizeRowHeadersWidth (DataGridViewRowHeadersWidthSizeMode rowHeadersWidthSizeMode, bool fixedColumnHeadersHeight, bool fixedRowsHeight) {
2251 throw new NotImplementedException();
2254 protected void AutoResizeRowHeadersWidth (int rowIndex, DataGridViewRowHeadersWidthSizeMode rowHeadersWidthSizeMode, bool fixedColumnHeadersHeight, bool fixedRowHeight) {
2255 throw new NotImplementedException();
2258 protected void AutoResizeRows (DataGridViewAutoSizeRowsMode autoSizeRowsMode, bool fixedWidth) {
2259 throw new NotImplementedException();
2262 protected void AutoResizeRows (int rowIndexStart, int rowsCount, DataGridViewAutoSizeRowMode autoSizeRowMode, bool fixedWidth) {
2263 throw new NotImplementedException();
2266 protected void ClearSelection (int columnIndexException, int rowIndexException, bool selectExceptionElement) {
2267 if (columnIndexException >= columns.Count) {
2268 throw new ArgumentOutOfRangeException("ColumnIndexException is greater than the highest column index.");
2270 if (selectionMode == DataGridViewSelectionMode.FullRowSelect) {
2271 if (columnIndexException < -1) {
2272 throw new ArgumentOutOfRangeException("ColumnIndexException is less than -1.");
2276 if (columnIndexException < 0) {
2277 throw new ArgumentOutOfRangeException("ColumnIndexException is less than 0.");
2280 if (rowIndexException >= rows.Count) {
2281 throw new ArgumentOutOfRangeException("RowIndexException is greater than the highest row index.");
2283 if (selectionMode == DataGridViewSelectionMode.FullColumnSelect) {
2284 if (rowIndexException < -1) {
2285 throw new ArgumentOutOfRangeException("RowIndexException is less than -1.");
2289 if (rowIndexException < 0) {
2290 throw new ArgumentOutOfRangeException("RowIndexException is less than 0.");
2293 switch (selectionMode) {
2294 case DataGridViewSelectionMode.FullRowSelect:
2295 foreach (DataGridViewRow row in rows) {
2296 if (selectExceptionElement && row.Index == rowIndexException) {
2299 row.Selected = false;
2302 case DataGridViewSelectionMode.FullColumnSelect:
2303 foreach (DataGridViewColumn col in columns) {
2304 if (selectExceptionElement && col.Index == columnIndexException) {
2307 col.Selected = false;
2311 foreach (DataGridViewCell cell in SelectedCells) {
2312 if (selectExceptionElement && cell.RowIndex == rowIndexException && cell.ColumnIndex == columnIndexException) {
2315 cell.Selected = false;
2321 protected override AccessibleObject CreateAccessibilityInstance ()
2323 return new DataGridViewAccessibleObject(this);
2326 [EditorBrowsable (EditorBrowsableState.Advanced)]
2327 protected virtual DataGridViewColumnCollection CreateColumnsInstance ()
2329 return new DataGridViewColumnCollection(this);
2332 protected override Control.ControlCollection CreateControlsInstance ()
2334 return base.CreateControlsInstance(); //new Control.ControlCollection(this);
2337 [EditorBrowsable (EditorBrowsableState.Advanced)]
2338 protected virtual DataGridViewRowCollection CreateRowsInstance ()
2340 return new DataGridViewRowCollection(this);
2343 protected override void Dispose (bool disposing) {
2346 protected override AccessibleObject GetAccessibilityObjectById (int objectId)
2348 throw new NotImplementedException();
2351 protected override bool IsInputChar (char charCode)
2353 return base.IsInputChar(charCode);
2356 protected override bool IsInputKey (Keys keyData)
2358 return base.IsInputKey(keyData);
2361 protected virtual void OnAllowUserToAddRowsChanged (EventArgs e)
2363 EventHandler eh = (EventHandler)(Events [AllowUserToAddRowsChangedEvent]);
2368 protected virtual void OnAllowUserToDeleteRowsChanged (EventArgs e)
2370 EventHandler eh = (EventHandler)(Events [AllowUserToDeleteRowsChangedEvent]);
2375 protected virtual void OnAllowUserToOrderColumnsChanged (EventArgs e)
2377 EventHandler eh = (EventHandler)(Events [AllowUserToOrderColumnsChangedEvent]);
2382 protected virtual void OnAllowUserToResizeColumnsChanged (EventArgs e)
2384 EventHandler eh = (EventHandler)(Events [AllowUserToResizeColumnsChangedEvent]);
2389 protected virtual void OnAllowUserToResizeRowsChanged (EventArgs e)
2391 EventHandler eh = (EventHandler)(Events [AllowUserToResizeRowsChangedEvent]);
2396 protected virtual void OnAlternatingRowsDefaultCellStyleChanged (EventArgs e)
2398 EventHandler eh = (EventHandler)(Events [AlternatingRowsDefaultCellStyleChangedEvent]);
2403 protected virtual void OnAutoGenerateColumnsChanged (EventArgs e)
2405 EventHandler eh = (EventHandler)(Events [AutoGenerateColumnsChangedEvent]);
2410 protected virtual void OnAutoSizeColumnModeChanged (DataGridViewAutoSizeColumnModeEventArgs e)
2412 DataGridViewAutoSizeColumnModeEventHandler eh = (DataGridViewAutoSizeColumnModeEventHandler)(Events [AutoSizeColumnModeChangedEvent]);
2417 protected virtual void OnAutoSizeColumnsModeChanged (DataGridViewAutoSizeColumnsModeEventArgs e)
2419 DataGridViewAutoSizeColumnsModeEventHandler eh = (DataGridViewAutoSizeColumnsModeEventHandler)(Events [AutoSizeColumnsModeChangedEvent]);
2424 protected virtual void OnAutoSizeRowsModeChanged (DataGridViewAutoSizeModeEventArgs e)
2426 DataGridViewAutoSizeModeEventHandler eh = (DataGridViewAutoSizeModeEventHandler)(Events [AutoSizeRowsModeChangedEvent]);
2431 protected virtual void OnBackgroundColorChanged (EventArgs e)
2433 EventHandler eh = (EventHandler)(Events [BackgroundColorChangedEvent]);
2438 protected override void OnBindingContextChanged (EventArgs e)
2440 base.OnBindingContextChanged(e);
2443 protected virtual void OnBorderStyleChanged (EventArgs e)
2445 EventHandler eh = (EventHandler)(Events [BorderStyleChangedEvent]);
2450 protected virtual void OnCancelRowEdit (QuestionEventArgs e) {
2451 QuestionEventHandler eh = (QuestionEventHandler)(Events [CancelRowEditEvent]);
2456 protected virtual void OnCellBeginEdit (DataGridViewCellCancelEventArgs e)
2458 DataGridViewCellCancelEventHandler eh = (DataGridViewCellCancelEventHandler)(Events [CellBeginEditEvent]);
2463 protected virtual void OnCellBorderStyleChanged (EventArgs e)
2465 EventHandler eh = (EventHandler)(Events [CellBorderStyleChangedEvent]);
2470 protected virtual void OnCellClick (DataGridViewCellEventArgs e)
2472 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellClickEvent]);
2477 protected virtual void OnCellContentClick (DataGridViewCellEventArgs e)
2479 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellContentClickEvent]);
2484 protected virtual void OnCellContentDoubleClick (DataGridViewCellEventArgs e)
2486 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellContentDoubleClickEvent]);
2491 protected virtual void OnCellContextMenuStripChanged (DataGridViewCellEventArgs e)
2493 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellContextMenuStripChangedEvent]);
2498 protected virtual void OnCellContextMenuStripNeeded (DataGridViewCellContextMenuStripNeededEventArgs e)
2500 DataGridViewCellContextMenuStripNeededEventHandler eh = (DataGridViewCellContextMenuStripNeededEventHandler)(Events [CellContextMenuStripNeededEvent]);
2505 protected virtual void OnCellDoubleClick (DataGridViewCellEventArgs e)
2507 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellDoubleClickEvent]);
2512 protected virtual void OnCellEndEdit (DataGridViewCellEventArgs e)
2514 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellEndEditEvent]);
2519 protected virtual void OnCellEnter (DataGridViewCellEventArgs e)
2521 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellEnterEvent]);
2526 protected internal virtual void OnCellErrorTextChanged (DataGridViewCellEventArgs e)
2528 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellErrorTextChangedEvent]);
2533 protected virtual void OnCellErrorTextNeeded (DataGridViewCellErrorTextNeededEventArgs e)
2535 DataGridViewCellErrorTextNeededEventHandler eh = (DataGridViewCellErrorTextNeededEventHandler)(Events [CellErrorTextNeededEvent]);
2540 protected virtual void OnCellFormatting (DataGridViewCellFormattingEventArgs e)
2542 DataGridViewCellFormattingEventHandler eh = (DataGridViewCellFormattingEventHandler)(Events [CellFormattingEvent]);
2547 protected virtual void OnCellLeave (DataGridViewCellEventArgs e)
2549 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellLeaveEvent]);
2554 protected virtual void OnCellMouseClick (DataGridViewCellMouseEventArgs e)
2556 DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [CellMouseClickEvent]);
2561 protected virtual void OnCellMouseDoubleClick (DataGridViewCellMouseEventArgs e)
2563 DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [CellMouseDoubleClickEvent]);
2568 protected virtual void OnCellMouseDown (DataGridViewCellMouseEventArgs e)
2570 DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [CellMouseDownEvent]);
2575 protected virtual void OnCellMouseEnter (DataGridViewCellEventArgs e)
2577 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellMouseEnterEvent]);
2582 protected virtual void OnCellMouseLeave (DataGridViewCellEventArgs e)
2584 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellMouseLeaveEvent]);
2589 protected virtual void OnCellMouseMove (DataGridViewCellMouseEventArgs e)
2591 DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [CellMouseMoveEvent]);
2596 protected virtual void OnCellMouseUp (DataGridViewCellMouseEventArgs e)
2598 DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [CellMouseUpEvent]);
2603 protected virtual void OnCellPainting (DataGridViewCellPaintingEventArgs e)
2605 DataGridViewCellPaintingEventHandler eh = (DataGridViewCellPaintingEventHandler)(Events [CellPaintingEvent]);
2610 protected internal virtual void OnCellParsing (DataGridViewCellParsingEventArgs e)
2612 DataGridViewCellParsingEventHandler eh = (DataGridViewCellParsingEventHandler)(Events [CellParsingEvent]);
2617 protected virtual void OnCellStateChanged (DataGridViewCellStateChangedEventArgs e)
2619 DataGridViewCellStateChangedEventHandler eh = (DataGridViewCellStateChangedEventHandler)(Events [CellStateChangedEvent]);
2624 protected virtual void OnCellStyleChanged (DataGridViewCellEventArgs e)
2626 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellStyleChangedEvent]);
2631 protected virtual void OnCellStyleContentChanged (DataGridViewCellStyleContentChangedEventArgs e) {
2632 DataGridViewCellStyleContentChangedEventHandler eh = (DataGridViewCellStyleContentChangedEventHandler)(Events [CellStyleContentChangedEvent]);
2637 protected virtual void OnCellToolTipTextChanged (DataGridViewCellEventArgs e) {
2638 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellToolTipTextChangedEvent]);
2643 protected virtual void OnCellToolTipTextNeeded (DataGridViewCellToolTipTextNeededEventArgs e)
2645 DataGridViewCellToolTipTextNeededEventHandler eh = (DataGridViewCellToolTipTextNeededEventHandler)(Events [CellToolTipTextNeededEvent]);
2650 protected virtual void OnCellValidated (DataGridViewCellEventArgs e)
2652 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellValidatedEvent]);
2657 protected virtual void OnCellValidating (DataGridViewCellValidatingEventArgs e)
2659 DataGridViewCellValidatingEventHandler eh = (DataGridViewCellValidatingEventHandler)(Events [CellValidatingEvent]);
2664 protected virtual void OnCellValueChanged (DataGridViewCellEventArgs e)
2666 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellValueChangedEvent]);
2671 protected virtual void OnCellValueNeeded (DataGridViewCellValueEventArgs e)
2673 DataGridViewCellValueEventHandler eh = (DataGridViewCellValueEventHandler)(Events [CellValueNeededEvent]);
2678 protected virtual void OnCellValuePushed (DataGridViewCellValueEventArgs e)
2680 DataGridViewCellValueEventHandler eh = (DataGridViewCellValueEventHandler)(Events [CellValuePushedEvent]);
2685 protected virtual void OnColumnAdded (DataGridViewColumnEventArgs e)
2687 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnAddedEvent]);
2692 protected internal virtual void OnColumnContextMenuStripChanged (DataGridViewColumnEventArgs e)
2694 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnContextMenuStripChangedEvent]);
2699 protected internal virtual void OnColumnDataPropertyNameChanged (DataGridViewColumnEventArgs e)
2701 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnDataPropertyNameChangedEvent]);
2706 protected internal virtual void OnColumnDefaultCellStyleChanged (DataGridViewColumnEventArgs e)
2708 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnDefaultCellStyleChangedEvent]);
2713 protected internal virtual void OnColumnDisplayIndexChanged (DataGridViewColumnEventArgs e)
2715 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnDisplayIndexChangedEvent]);
2720 protected virtual void OnColumnDividerDoubleClick (DataGridViewColumnDividerDoubleClickEventArgs e)
2722 DataGridViewColumnDividerDoubleClickEventHandler eh = (DataGridViewColumnDividerDoubleClickEventHandler)(Events [ColumnDividerDoubleClickEvent]);
2727 protected internal virtual void OnColumnDividerWidthChanged (DataGridViewColumnEventArgs e)
2729 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnDividerWidthChangedEvent]);
2734 protected internal virtual void OnColumnHeaderCellChanged (DataGridViewColumnEventArgs e)
2736 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnHeaderCellChangedEvent]);
2741 protected virtual void OnColumnHeaderMouseClick (DataGridViewCellMouseEventArgs e)
2743 DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [ColumnHeaderMouseClickEvent]);
2748 protected virtual void OnColumnHeaderMouseDoubleClick (DataGridViewCellMouseEventArgs e)
2750 DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [ColumnHeaderMouseDoubleClickEvent]);
2755 protected virtual void OnColumnHeadersBorderStyleChanged (EventArgs e)
2757 EventHandler eh = (EventHandler)(Events [ColumnHeadersBorderStyleChangedEvent]);
2762 protected virtual void OnColumnHeadersDefaultCellStyleChanged (EventArgs e)
2764 EventHandler eh = (EventHandler)(Events [ColumnHeadersDefaultCellStyleChangedEvent]);
2769 protected virtual void OnColumnHeadersHeightChanged (EventArgs e)
2771 EventHandler eh = (EventHandler)(Events [ColumnHeadersHeightChangedEvent]);
2776 protected virtual void OnColumnHeadersHeightSizeModeChanged (DataGridViewAutoSizeModeEventArgs e)
2778 DataGridViewAutoSizeModeEventHandler eh = (DataGridViewAutoSizeModeEventHandler)(Events [ColumnHeadersHeightSizeModeChangedEvent]);
2783 protected internal virtual void OnColumnMinimumWidthChanged (DataGridViewColumnEventArgs e)
2785 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnMinimumWidthChangedEvent]);
2790 protected internal virtual void OnColumnNameChanged (DataGridViewColumnEventArgs e)
2792 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnNameChangedEvent]);
2797 protected virtual void OnColumnRemoved (DataGridViewColumnEventArgs e)
2799 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnRemovedEvent]);
2804 protected internal virtual void OnColumnSortModeChanged (DataGridViewColumnEventArgs e)
2806 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnSortModeChangedEvent]);
2811 protected internal virtual void OnColumnStateChanged (DataGridViewColumnStateChangedEventArgs e)
2813 DataGridViewColumnStateChangedEventHandler eh = (DataGridViewColumnStateChangedEventHandler)(Events [ColumnStateChangedEvent]);
2818 protected internal virtual void OnColumnToolTipTextChanged (DataGridViewColumnEventArgs e)
2820 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnToolTipTextChangedEvent]);
2825 protected internal virtual void OnColumnWidthChanged (DataGridViewColumnEventArgs e)
2827 DataGridViewColumnEventHandler eh = (DataGridViewColumnEventHandler)(Events [ColumnWidthChangedEvent]);
2832 protected virtual void OnCurrentCellChanged (EventArgs e)
2834 EventHandler eh = (EventHandler)(Events [CurrentCellChangedEvent]);
2839 protected virtual void OnCurrentCellDirtyStateChanged (EventArgs e)
2841 EventHandler eh = (EventHandler)(Events [CurrentCellDirtyStateChangedEvent]);
2846 protected override void OnCursorChanged (EventArgs e)
2848 base.OnCursorChanged (e);
2851 protected virtual void OnDataBindingComplete (DataGridViewBindingCompleteEventArgs e)
2853 DataGridViewBindingCompleteEventHandler eh = (DataGridViewBindingCompleteEventHandler)(Events [DataBindingCompleteEvent]);
2858 protected virtual void OnDataError (bool displayErrorDialogIfNoHandler, DataGridViewDataErrorEventArgs e) {
2859 DataGridViewDataErrorEventHandler eh = (DataGridViewDataErrorEventHandler)(Events [DataErrorEvent]);
2864 if (displayErrorDialogIfNoHandler) {
2865 /////////////////////////////////// ERROR DIALOG //////////////////////////////////7
2869 protected virtual void OnDataMemberChanged (EventArgs e) {
2870 EventHandler eh = (EventHandler)(Events [DataMemberChangedEvent]);
2875 protected virtual void OnDataSourceChanged (EventArgs e) {
2876 EventHandler eh = (EventHandler)(Events [DataSourceChangedEvent]);
2881 protected virtual void OnDefaultCellStyleChanged (EventArgs e) {
2882 EventHandler eh = (EventHandler)(Events [DefaultCellStyleChangedEvent]);
2887 protected virtual void OnDefaultValuesNeeded (DataGridViewRowEventArgs e) {
2888 DataGridViewRowEventHandler eh = (DataGridViewRowEventHandler)(Events [DefaultValuesNeededEvent]);
2893 protected override void OnDoubleClick (EventArgs e) {
2894 base.OnDoubleClick(e);
2897 protected virtual void OnEditingControlShowing (DataGridViewEditingControlShowingEventArgs e) {
2898 DataGridViewEditingControlShowingEventHandler eh = (DataGridViewEditingControlShowingEventHandler)(Events [EditingControlShowingEvent]);
2903 protected virtual void OnEditModeChanged (EventArgs e)
2905 EventHandler eh = (EventHandler)(Events [EditModeChangedEvent]);
2910 protected override void OnEnabledChanged (EventArgs e)
2912 base.OnEnabledChanged(e);
2915 protected override void OnEnter (EventArgs e )
2920 protected override void OnGotFocus(EventArgs e)
2922 base.OnGotFocus (e);
2925 protected override void OnFontChanged (EventArgs e)
2927 base.OnFontChanged(e);
2930 protected override void OnForeColorChanged (EventArgs e)
2932 base.OnForeColorChanged(e);
2935 protected virtual void OnGridColorChanged (EventArgs e)
2937 EventHandler eh = (EventHandler)(Events [GridColorChangedEvent]);
2942 protected override void OnHandleCreated (EventArgs e)
2944 base.OnHandleCreated(e);
2947 protected override void OnHandleDestroyed(EventArgs e)
2949 base.OnHandleDestroyed (e);
2952 [EditorBrowsable (EditorBrowsableState.Advanced)]
2953 protected override void OnKeyDown (KeyEventArgs e)
2958 [EditorBrowsable (EditorBrowsableState.Advanced)]
2959 protected override void OnKeyPress (KeyPressEventArgs e)
2964 [EditorBrowsable (EditorBrowsableState.Advanced)]
2965 protected override void OnKeyUp (KeyEventArgs e)
2970 protected override void OnLayout (LayoutEventArgs e)
2975 protected override void OnLeave (EventArgs e)
2980 protected override void OnLostFocus(EventArgs e)
2982 base.OnLostFocus (e);
2985 protected override void OnMouseClick (MouseEventArgs e)
2987 base.OnMouseClick(e);
2988 //Console.WriteLine("Mouse: Clicks: {0}; Delta: {1}; X: {2}; Y: {3};", e.Clicks, e.Delta, e.X, e.Y);
2991 protected override void OnMouseDoubleClick (MouseEventArgs e)
2993 base.OnMouseDoubleClick(e);
2996 protected override void OnMouseDown (MouseEventArgs e)
2998 base.OnMouseDown(e);
2999 //Console.WriteLine("Mouse: Clicks: {0}; Delta: {1}; X: {2}; Y: {3};", e.Clicks, e.Delta, e.X, e.Y);
3000 HitTestInfo hitTest = HitTest(e.X, e.Y);
3001 //Console.WriteLine("HitTest: Column: {0}; Row: {1};", hitTest.ColumnIndex, hitTest.RowIndex);
3002 if (hitTest.RowIndex < 0 || hitTest.ColumnIndex < 0) {
3005 OnCellClick(new DataGridViewCellEventArgs(hitTest.ColumnIndex, hitTest.RowIndex));
3006 DataGridViewRow row = rows[hitTest.RowIndex];
3007 DataGridViewCell cell = row.Cells[hitTest.ColumnIndex];
3008 ClearSelection(0, 0, false);
3009 switch (selectionMode) {
3010 case DataGridViewSelectionMode.FullRowSelect:
3011 row.Selected = true;
3013 case DataGridViewSelectionMode.FullColumnSelect:
3017 cell.Selected = true;
3020 if (cell == currentCell) {
3021 currentCell.SetIsInEditMode(true);
3022 OnCellBeginEdit(new DataGridViewCellCancelEventArgs(currentCell.ColumnIndex, currentCell.RowIndex));
3026 if (currentCell != null) {
3027 if (currentCell.IsInEditMode) {
3028 currentCell.SetIsInEditMode(false);
3029 currentCell.DetachEditingControl();
3030 OnCellEndEdit(new DataGridViewCellEventArgs(currentCell.ColumnIndex, currentCell.RowIndex));
3032 OnCellLeave(new DataGridViewCellEventArgs(currentCell.ColumnIndex, currentCell.RowIndex));
3035 OnCurrentCellChanged(EventArgs.Empty);
3036 OnCellEnter(new DataGridViewCellEventArgs(cell.ColumnIndex, cell.RowIndex));
3037 if (editMode == DataGridViewEditMode.EditOnEnter) {
3038 currentCell.SetIsInEditMode(true);
3039 OnCellBeginEdit(new DataGridViewCellCancelEventArgs(currentCell.ColumnIndex, currentCell.RowIndex));
3045 protected override void OnMouseEnter (EventArgs e)
3047 base.OnMouseEnter(e);
3050 protected override void OnMouseLeave (EventArgs e)
3052 base.OnMouseLeave(e);
3055 protected override void OnMouseMove (MouseEventArgs e)
3057 base.OnMouseMove(e);
3060 protected override void OnMouseUp (MouseEventArgs e)
3065 protected override void OnMouseWheel (MouseEventArgs e)
3067 base.OnMouseWheel(e);
3070 protected virtual void OnMultiSelectChanged (EventArgs e)
3072 EventHandler eh = (EventHandler)(Events [MultiSelectChangedEvent]);
3073 if (eh != null) eh (this, e);
3076 protected virtual void OnNewRowNeeded (DataGridViewRowEventArgs e) {
3077 DataGridViewRowEventHandler eh = (DataGridViewRowEventHandler)(Events [NewRowNeededEvent]);
3078 if (eh != null) eh (this, e);
3081 protected override void OnPaint (PaintEventArgs e) {
3083 //Console.WriteLine("DataGridView.OnPaint-ClipRectangle: {0};", e.ClipRectangle);
3084 Rectangle bounds = ClientRectangle; //e.ClipRectangle;
3085 e.Graphics.FillRectangle(new SolidBrush(backgroundColor), bounds);
3086 Pen pen = new Pen(gridColor);
3089 ArrayList sortedColumns = columns.ColumnDisplayIndexSortedArrayList;
3090 bounds.Y = -verticalScrollingOffset;
3091 bounds.X = -horizontalScrollingOffset;
3093 foreach (DataGridViewColumn col in sortedColumns) {
3094 gridWidth += col.Width;
3096 if (columnHeadersVisible) {
3097 Rectangle headerBounds = bounds;
3098 if (rowHeadersVisible) {
3099 headerBounds.X += rowHeadersWidth;
3101 headerBounds.Height = columnHeadersHeight;
3103 foreach (DataGridViewColumn col in sortedColumns) {
3104 headerBounds.Width = col.Width;
3105 DataGridViewCell cell = col.HeaderCell;
3106 DataGridViewCellStyle style = columnHeadersDefaultCellStyle;
3107 DataGridViewAdvancedBorderStyle intermediateBorderStyle = (DataGridViewAdvancedBorderStyle) ((ICloneable)this.AdvancedColumnHeadersBorderStyle).Clone();
3108 DataGridViewAdvancedBorderStyle borderStyle = AdjustColumnHeaderBorderStyle(this.AdvancedColumnHeadersBorderStyle, intermediateBorderStyle, j == 0, j == columns.Count - 1);
3109 cell.InternalPaint(e.Graphics, e.ClipRectangle, headerBounds, cell.RowIndex, cell.State, cell.Value, cell.FormattedValue, cell.ErrorText, style, borderStyle, DataGridViewPaintParts.All);
3110 headerBounds.X += col.Width;
3113 bounds.Y += columnHeadersHeight;
3116 foreach (DataGridViewRow row in rows) {
3117 gridHeight += row.Height;
3118 if (rowHeadersVisible) {
3119 Rectangle rowHeaderBounds = bounds;
3120 rowHeaderBounds.Height = row.Height;
3121 rowHeaderBounds.Width = rowHeadersWidth;
3122 DataGridViewCell cell = row.HeaderCell;
3123 DataGridViewCellStyle style = rowHeadersDefaultCellStyle;
3124 DataGridViewAdvancedBorderStyle intermediateBorderStyle = (DataGridViewAdvancedBorderStyle) ((ICloneable)this.AdvancedRowHeadersBorderStyle).Clone();
3125 DataGridViewAdvancedBorderStyle borderStyle = cell.AdjustCellBorderStyle(this.AdvancedRowHeadersBorderStyle, intermediateBorderStyle, true, true, false, cell.RowIndex == 0);
3126 cell.InternalPaint(e.Graphics, e.ClipRectangle, rowHeaderBounds, cell.RowIndex, cell.State, cell.Value, cell.FormattedValue, cell.ErrorText, style, borderStyle, DataGridViewPaintParts.All);
3127 //e.Graphics.FillRectangle(new SolidBrush(rowHeadersDefaultCellStyle.BackColor), rowHeadersBounds);
3128 bounds.X += rowHeadersWidth;
3130 bounds.Height = row.Height;
3131 for (int j = 0; j < sortedColumns.Count; j++) {
3132 DataGridViewColumn col = (DataGridViewColumn) sortedColumns[j];
3133 foreach (DataGridViewCell cell in row.Cells) {
3134 if (cell.ColumnIndex == col.Index) {
3135 bounds.Width = col.Width;
3136 cell.SetSize(new Size(bounds.Width, bounds.Height));
3137 DataGridViewCellStyle style = cell.InheritedStyle;
3138 if (cell == currentCell && cell.IsInEditMode) {
3139 cell.InitializeEditingControl(cell.RowIndex, cell.FormattedValue, style);
3140 cell.PositionEditingControl(true, true, bounds, e.ClipRectangle, style, false, false, (columns[currentCell.ColumnIndex].DisplayIndex == 0), (currentCell.RowIndex == 0));
3143 DataGridViewAdvancedBorderStyle intermediateBorderStyle = (DataGridViewAdvancedBorderStyle) ((ICloneable)this.AdvancedCellBorderStyle).Clone();
3144 DataGridViewAdvancedBorderStyle borderStyle = cell.AdjustCellBorderStyle(this.AdvancedCellBorderStyle, intermediateBorderStyle, true, true, j == 0, cell.RowIndex == 0);
3145 OnCellFormatting(new DataGridViewCellFormattingEventArgs(cell.ColumnIndex, cell.RowIndex, cell.Value, cell.FormattedValueType, style));
3146 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);
3147 OnCellPainting(args);
3148 if (!args.Handled) {
3149 cell.InternalPaint(e.Graphics, e.ClipRectangle, bounds, cell.RowIndex, cell.State, cell.Value, cell.FormattedValue, cell.ErrorText, style, borderStyle, DataGridViewPaintParts.All);
3152 bounds.X += bounds.Width;
3156 bounds.Y += bounds.Height;
3157 bounds.X = -horizontalScrollingOffset;
3160 if (rowHeadersVisible) {
3161 gridWidth += rowHeadersWidth;
3163 if (columnHeadersVisible) {
3164 gridHeight += columnHeadersHeight;
3166 horizontalScrollBar.Visible = false;
3167 verticalScrollBar.Visible = false;
3169 if (gridWidth > Size.Width || gridHeight > Size.Height) {
3170 Size = new Size(gridWidth, gridHeight);
3174 if (gridWidth > Size.Width) {
3175 horizontalScrollBar.Visible = true;
3177 if (gridHeight > Size.Height) {
3178 verticalScrollBar.Visible = true;
3180 if (horizontalScrollBar.Visible && (gridHeight + horizontalScrollBar.Height) > Size.Height) {
3181 verticalScrollBar.Visible = true;
3183 if (verticalScrollBar.Visible && (gridWidth + verticalScrollBar.Width) > Size.Width) {
3184 horizontalScrollBar.Visible = true;
3186 if (horizontalScrollBar.Visible) {
3187 horizontalScrollBar.Minimum = 0;
3188 if (verticalScrollBar.Visible) {
3189 horizontalScrollBar.Maximum = gridWidth - ClientRectangle.Width + verticalScrollBar.Width;
3192 horizontalScrollBar.Maximum = gridWidth - ClientRectangle.Width;
3194 horizontalScrollBar.LargeChange = horizontalScrollBar.Maximum / 10;
3195 horizontalScrollBar.SmallChange = horizontalScrollBar.Maximum / 20;
3197 if (verticalScrollBar.Visible) {
3198 verticalScrollBar.Minimum = 0;
3199 if (horizontalScrollBar.Visible) {
3200 verticalScrollBar.Maximum = gridHeight - ClientRectangle.Height + horizontalScrollBar.Height;
3203 verticalScrollBar.Maximum = gridHeight - ClientRectangle.Height;
3205 verticalScrollBar.LargeChange = verticalScrollBar.Maximum / 10;
3206 verticalScrollBar.SmallChange = verticalScrollBar.Maximum / 20;
3209 if (horizontalScrollBar.Visible && !this.Controls.Contains(horizontalScrollBar)) {
3210 this.Controls.Add(horizontalScrollBar);
3212 else if (!horizontalScrollBar.Visible && this.Controls.Contains(horizontalScrollBar)) {
3213 this.Controls.Remove(horizontalScrollBar);
3215 if (verticalScrollBar.Visible && !this.Controls.Contains(verticalScrollBar)) {
3216 this.Controls.Add(verticalScrollBar);
3218 else if (!verticalScrollBar.Visible && this.Controls.Contains(verticalScrollBar)) {
3219 this.Controls.Remove(verticalScrollBar);
3223 protected virtual void OnReadOnlyChanged (EventArgs e) {
3224 EventHandler eh = (EventHandler)(Events [ReadOnlyChangedEvent]);
3229 protected override void OnResize (EventArgs e) {
3231 horizontalScrollingOffset = ((gridWidth - Size.Width) > 0)? (gridWidth - Size.Width) : 0;
3232 verticalScrollingOffset = ((gridHeight - Size.Height) > 0)? (gridHeight - Size.Height) : 0;
3236 protected override void OnRightToLeftChanged (EventArgs e) {
3237 base.OnRightToLeftChanged(e);
3240 // In MSDN2 documentation there's no internal here
3241 protected internal virtual void OnRowContextMenuStripChanged (DataGridViewRowEventArgs e)
3243 DataGridViewRowEventHandler eh = (DataGridViewRowEventHandler)(Events [RowContextMenuStripChangedEvent]);
3244 if (eh != null) eh (this, e);
3247 protected virtual void OnRowContextMenuStripNeeded (DataGridViewRowContextMenuStripNeededEventArgs e)
3249 DataGridViewRowContextMenuStripNeededEventHandler eh = (DataGridViewRowContextMenuStripNeededEventHandler)(Events [RowContextMenuStripNeededEvent]);
3250 if (eh != null) eh (this, e);
3253 protected internal virtual void OnRowDefaultCellStyleChanged (DataGridViewRowEventArgs e)
3255 DataGridViewRowEventHandler eh = (DataGridViewRowEventHandler)(Events [RowDefaultCellStyleChangedEvent]);
3256 if (eh != null) eh (this, e);
3259 protected virtual void OnRowDirtyStateNeeded (QuestionEventArgs e)
3261 QuestionEventHandler eh = (QuestionEventHandler)(Events [RowDirtyStateNeededEvent]);
3262 if (eh != null) eh (this, e);
3265 protected virtual void OnRowDividerDoubleClick (DataGridViewRowDividerDoubleClickEventArgs e)
3267 DataGridViewRowDividerDoubleClickEventHandler eh = (DataGridViewRowDividerDoubleClickEventHandler)(Events [RowDividerDoubleClickEvent]);
3268 if (eh != null) eh (this, e);
3271 protected virtual void OnRowDividerHeightChanged (DataGridViewRowEventArgs e)
3273 DataGridViewRowEventHandler eh = (DataGridViewRowEventHandler)(Events [RowDividerHeightChangedEvent]);
3274 if (eh != null) eh (this, e);
3277 protected virtual void OnRowEnter (DataGridViewCellEventArgs e)
3279 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [RowEnterEvent]);
3280 if (eh != null) eh (this, e);
3283 protected internal virtual void OnRowErrorTextChanged (DataGridViewRowEventArgs e)
3285 DataGridViewRowEventHandler eh = (DataGridViewRowEventHandler)(Events [RowErrorTextChangedEvent]);
3286 if (eh != null) eh (this, e);
3289 protected virtual void OnRowErrorTextNeeded (DataGridViewRowErrorTextNeededEventArgs e)
3291 DataGridViewRowErrorTextNeededEventHandler eh = (DataGridViewRowErrorTextNeededEventHandler)(Events [RowErrorTextNeededEvent]);
3292 if (eh != null) eh (this, e);
3295 protected internal virtual void OnRowHeaderCellChanged (DataGridViewRowEventArgs e)
3297 DataGridViewRowEventHandler eh = (DataGridViewRowEventHandler)(Events [RowHeaderCellChangedEvent]);
3298 if (eh != null) eh (this, e);
3301 protected virtual void OnRowHeaderMouseClick (DataGridViewCellMouseEventArgs e)
3303 DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [RowHeaderMouseClickEvent]);
3304 if (eh != null) eh (this, e);
3307 protected virtual void OnRowHeaderMouseDoubleClick (DataGridViewCellMouseEventArgs e)
3309 DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [RowHeaderMouseDoubleClickEvent]);
3310 if (eh != null) eh (this, e);
3313 protected virtual void OnRowHeadersBorderStyleChanged (EventArgs e)
3315 EventHandler eh = (EventHandler)(Events [RowHeadersBorderStyleChangedEvent]);
3316 if (eh != null) eh (this, e);
3319 protected virtual void OnRowHeadersDefaultCellStyleChanged (EventArgs e)
3321 EventHandler eh = (EventHandler)(Events [RowHeadersDefaultCellStyleChangedEvent]);
3322 if (eh != null) eh (this, e);
3325 protected virtual void OnRowHeadersWidthChanged (EventArgs e)
3327 EventHandler eh = (EventHandler)(Events [RowHeadersWidthChangedEvent]);
3328 if (eh != null) eh (this, e);
3331 protected virtual void OnRowHeadersWidthSizeModeChanged (DataGridViewAutoSizeModeEventArgs e)
3333 DataGridViewAutoSizeModeEventHandler eh = (DataGridViewAutoSizeModeEventHandler)(Events [RowHeadersWidthSizeModeChangedEvent]);
3334 if (eh != null) eh (this, e);
3337 protected internal virtual void OnRowHeightChanged (DataGridViewRowEventArgs e)
3339 DataGridViewRowEventHandler eh = (DataGridViewRowEventHandler)(Events [RowHeightChangedEvent]);
3340 if (eh != null) eh (this, e);
3343 protected virtual void OnRowHeightInfoNeeded (DataGridViewRowHeightInfoNeededEventArgs e)
3345 DataGridViewRowHeightInfoNeededEventHandler eh = (DataGridViewRowHeightInfoNeededEventHandler)(Events [RowHeightInfoNeededEvent]);
3346 if (eh != null) eh (this, e);
3349 protected virtual void OnRowHeightInfoPushed (DataGridViewRowHeightInfoPushedEventArgs e)
3351 DataGridViewRowHeightInfoPushedEventHandler eh = (DataGridViewRowHeightInfoPushedEventHandler)(Events [RowHeightInfoPushedEvent]);
3352 if (eh != null) eh (this, e);
3355 protected virtual void OnRowLeave (DataGridViewCellEventArgs e)
3357 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [RowLeaveEvent]);
3358 if (eh != null) eh (this, e);
3361 protected internal virtual void OnRowMinimumHeightChanged (DataGridViewRowEventArgs e)
3363 DataGridViewRowEventHandler eh = (DataGridViewRowEventHandler)(Events [RowMinimumHeightChangedEvent]);
3364 if (eh != null) eh (this, e);
3367 protected internal virtual void OnRowPostPaint (DataGridViewRowPostPaintEventArgs e)
3369 DataGridViewRowPostPaintEventHandler eh = (DataGridViewRowPostPaintEventHandler)(Events [RowPostPaintEvent]);
3370 if (eh != null) eh (this, e);
3373 protected internal virtual void OnRowPrePaint (DataGridViewRowPrePaintEventArgs e)
3375 DataGridViewRowPrePaintEventHandler eh = (DataGridViewRowPrePaintEventHandler)(Events [RowPrePaintEvent]);
3376 if (eh != null) eh (this, e);
3379 protected internal virtual void OnRowsAdded (DataGridViewRowsAddedEventArgs e)
3381 DataGridViewRowsAddedEventHandler eh = (DataGridViewRowsAddedEventHandler)(Events [RowsAddedEvent]);
3382 if (eh != null) eh (this, e);
3385 protected virtual void OnRowsDefaultCellStyleChanged (EventArgs e)
3387 EventHandler eh = (EventHandler)(Events [RowsDefaultCellStyleChangedEvent]);
3388 if (eh != null) eh (this, e);
3391 protected internal virtual void OnRowsRemoved (DataGridViewRowsRemovedEventArgs e)
3393 DataGridViewRowsRemovedEventHandler eh = (DataGridViewRowsRemovedEventHandler)(Events [RowsRemovedEvent]);
3394 if (eh != null) eh (this, e);
3397 protected internal virtual void OnRowStateChanged (int rowIndex, DataGridViewRowStateChangedEventArgs e)
3399 DataGridViewRowStateChangedEventHandler eh = (DataGridViewRowStateChangedEventHandler)(Events [RowStateChangedEvent]);
3400 if (eh != null) eh (this, e);
3403 protected virtual void OnRowUnshared (DataGridViewRowEventArgs e)
3405 DataGridViewRowEventHandler eh = (DataGridViewRowEventHandler)(Events [RowUnsharedEvent]);
3406 if (eh != null) eh (this, e);
3409 protected virtual void OnRowValidated (DataGridViewCellEventArgs e)
3411 DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [RowValidatedEvent]);
3412 if (eh != null) eh (this, e);
3415 protected virtual void OnRowValidating (DataGridViewCellCancelEventArgs e)
3417 DataGridViewCellCancelEventHandler eh = (DataGridViewCellCancelEventHandler)(Events [RowValidatingEvent]);
3418 if (eh != null) eh (this, e);
3421 protected virtual void OnScroll (ScrollEventArgs e)
3423 ScrollEventHandler eh = (ScrollEventHandler)(Events [ScrollEvent]);
3424 if (eh != null) eh (this, e);
3427 protected virtual void OnSelectionChanged (EventArgs e)
3429 EventHandler eh = (EventHandler)(Events [SelectionChangedEvent]);
3430 if (eh != null) eh (this, e);
3433 protected virtual void OnSortCompare (DataGridViewSortCompareEventArgs e) {
3434 DataGridViewSortCompareEventHandler eh = (DataGridViewSortCompareEventHandler)(Events [SortCompareEvent]);
3435 if (eh != null) eh (this, e);
3438 protected virtual void OnSorted (EventArgs e)
3440 EventHandler eh = (EventHandler)(Events [SortedEvent]);
3441 if (eh != null) eh (this, e);
3444 protected virtual void OnUserAddedRow (DataGridViewRowEventArgs e)
3446 DataGridViewRowEventHandler eh = (DataGridViewRowEventHandler)(Events [UserAddedRowEvent]);
3447 if (eh != null) eh (this, e);
3450 protected virtual void OnUserDeletedRow (DataGridViewRowEventArgs e)
3452 DataGridViewRowEventHandler eh = (DataGridViewRowEventHandler)(Events [UserDeletedRowEvent]);
3453 if (eh != null) eh (this, e);
3457 protected virtual void OnUserDeletingRow (DataGridViewRowCancelEventArgs e)
3459 DataGridViewRowCancelEventHandler eh = (DataGridViewRowCancelEventHandler)(Events [UserDeletingRowEvent]);
3460 if (eh != null) eh (this, e);
3463 protected override void OnValidating (CancelEventArgs e)
3465 base.OnValidating(e);
3468 protected override void OnVisibleChanged (EventArgs e)
3470 base.OnVisibleChanged(e);
3473 protected virtual void PaintBackground (Graphics graphics, Rectangle clipBounds, Rectangle gridBounds)
3477 protected bool ProcessAKey (Keys keyData)
3479 throw new NotImplementedException();
3482 protected virtual bool ProcessDataGridViewKey (KeyEventArgs e)
3484 throw new NotImplementedException();
3487 protected bool ProcessDeleteKey (Keys keyData)
3489 throw new NotImplementedException();
3492 protected override bool ProcessDialogKey (Keys keyData)
3494 return base.ProcessDialogKey(keyData);
3495 //throw new NotImplementedException();
3498 protected bool ProcessDownKey (Keys keyData) {
3499 throw new NotImplementedException();
3502 protected bool ProcessEndKey (Keys keyData) {
3503 throw new NotImplementedException();
3506 protected bool ProcessEnterKey (Keys keyData) {
3507 throw new NotImplementedException();
3510 protected bool ProcessEscapeKey (Keys keyData) {
3511 throw new NotImplementedException();
3514 protected bool ProcessF2Key (Keys keyData) {
3515 throw new NotImplementedException();
3518 protected bool ProcessHomeKey (Keys keyData) {
3519 throw new NotImplementedException();
3522 protected bool ProcessInsertKey (Keys keyData) {
3523 throw new NotImplementedException();
3526 protected override bool ProcessKeyEventArgs (ref Message m) {
3527 return base.ProcessKeyEventArgs(ref m);
3528 //throw new NotImplementedException();
3531 protected override bool ProcessKeyPreview (ref Message m) {
3532 return base.ProcessKeyPreview(ref m);
3533 //throw new NotImplementedException();
3536 protected bool ProcessLeftKey (Keys keyData) {
3537 throw new NotImplementedException();
3540 protected bool ProcessNextKey (Keys keyData) {
3542 throw new NotImplementedException();
3545 protected bool ProcessPriorKey (Keys keyData) {
3547 throw new NotImplementedException();
3550 protected bool ProcessRightKey (Keys keyData) {
3551 throw new NotImplementedException();
3554 protected bool ProcessSpaceKey (Keys keyData) {
3555 throw new NotImplementedException();
3558 protected bool ProcessTabKey (Keys keyData) {
3559 throw new NotImplementedException();
3562 protected bool ProcessUpKey (Keys keyData) {
3563 throw new NotImplementedException();
3566 protected bool ProcessZeroKey (Keys keyData) {
3567 throw new NotImplementedException();
3570 protected override void SetBoundsCore (int x, int y, int width, int height, BoundsSpecified specified) {
3571 base.SetBoundsCore(x, y, width, height, specified);
3574 protected virtual bool SetCurrentCellAddressCore (int columnIndex, int rowIndex, bool setAnchorCellAddress, bool validateCurrentCell, bool throughMouseClick) {
3575 throw new NotImplementedException();
3578 protected virtual void SetSelectedCellCore (int columnIndex, int rowIndex, bool selected) {
3579 throw new NotImplementedException();
3582 protected virtual void SetSelectedColumnCore (int columnIndex, bool selected) {
3583 throw new NotImplementedException();
3586 protected virtual void SetSelectedRowCore (int rowIndex, bool selected) {
3587 throw new NotImplementedException();
3590 protected override void WndProc (ref Message m) {
3591 base.WndProc(ref m);
3594 void IDropTarget.OnDragDrop (DragEventArgs e)
3596 throw new NotImplementedException ();
3599 void IDropTarget.OnDragEnter (DragEventArgs e)
3601 throw new NotImplementedException ();
3604 void IDropTarget.OnDragLeave (EventArgs e)
3606 throw new NotImplementedException ();
3609 void IDropTarget.OnDragOver (DragEventArgs e)
3611 throw new NotImplementedException ();
3614 internal void InternalOnCellClick (DataGridViewCellEventArgs e) {
3618 internal void InternalOnCellContentClick (DataGridViewCellEventArgs e) {
3619 OnCellContentClick(e);
3622 internal void InternalOnCellContentDoubleClick (DataGridViewCellEventArgs e) {
3623 OnCellContentDoubleClick(e);
3626 internal void InternalOnCellValueChanged (DataGridViewCellEventArgs e) {
3627 OnCellValueChanged(e);
3630 internal void InternalOnDataError (DataGridViewDataErrorEventArgs e) {
3631 /////////////// false? ////////////
3632 OnDataError(false, e);
3635 internal void InternalOnMouseWheel (MouseEventArgs e) {
3639 internal void OnHScrollBarScroll (object sender, ScrollEventArgs e) {
3640 horizontalScrollingOffset = e.NewValue;
3645 internal void OnVScrollBarScroll (object sender, ScrollEventArgs e) {
3646 verticalScrollingOffset = e.NewValue;
3651 internal void RaiseCellStyleChanged (DataGridViewCellEventArgs e) {
3652 OnCellStyleChanged(e);
3655 internal void OnColumnCollectionChanged (object sender, CollectionChangeEventArgs e) {
3657 case CollectionChangeAction.Add:
3658 OnColumnAdded(new DataGridViewColumnEventArgs(e.Element as DataGridViewColumn));
3660 case CollectionChangeAction.Remove:
3661 OnColumnRemoved(new DataGridViewColumnEventArgs(e.Element as DataGridViewColumn));
3663 case CollectionChangeAction.Refresh:
3668 private void BindIList (IList list) {
3669 if (list is DataView) {
3670 DataView dataView = (DataView) list;
3671 DataTable table = dataView.Table;
3672 DataGridViewCell template = new DataGridViewTextBoxCell();
3673 foreach (DataColumn dataColumn in table.Columns) {
3674 DataGridViewColumn col = new DataGridViewColumn(template);
3675 col.Name = dataColumn.ColumnName;
3676 col.ValueType = dataColumn.DataType;
3679 dataView.ListChanged += OnListChanged;
3681 else if (list.Count > 0) {
3682 DataGridViewCell template = new DataGridViewTextBoxCell();
3683 foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(list[0])) {
3684 DataGridViewColumn col = new DataGridViewColumn(template);
3685 col.Name = property.DisplayName;
3689 foreach (object element in list) {
3690 DataGridViewRow row = new DataGridViewRow();
3691 rows.InternalAdd(row);
3692 PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(element);
3693 foreach (PropertyDescriptor property in properties) {
3694 DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell();
3695 cell.Value = property.GetValue(element);
3696 cell.ValueType = property.PropertyType;
3697 row.Cells.Add(cell);
3702 private void BindIListSource (IListSource list) {
3703 BindIList(list.GetList());
3706 private void BindIBindingList (IBindingList list) {
3710 private void BindIBindingListView (IBindingListView list) {
3714 private void OnListChanged (object sender, ListChangedEventArgs args) {
3715 if (args.OldIndex >= 0) {
3717 if (args.NewIndex >= 0) {
3718 object element = (sender as DataView)[args.NewIndex];
3719 DataGridViewRow row = new DataGridViewRow();
3720 rows.InternalAdd(row);
3721 PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(element);
3722 foreach (PropertyDescriptor property in properties) {
3723 DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell();
3724 cell.Value = property.GetValue(element);
3725 cell.ValueType = property.PropertyType;
3726 row.Cells.Add(cell);
3732 public sealed class HitTestInfo {
3734 public static readonly HitTestInfo Nowhere = new HitTestInfo(-1, -1, -1, -1, DataGridViewHitTestType.None);
3736 private int columnIndex;
3737 private int columnX;
3738 private int rowIndex;
3740 private DataGridViewHitTestType type;
3742 internal HitTestInfo (int columnIndex, int columnX, int rowIndex, int rowY, DataGridViewHitTestType type) {
3743 this.columnIndex = columnIndex;
3744 this.columnX = columnX;
3745 this.rowIndex = rowIndex;
3750 public int ColumnIndex {
3751 get { return columnIndex; }
3754 public int ColumnX {
3755 get { return columnX; }
3758 public int RowIndex {
3759 get { return rowIndex; }
3763 get { return rowY; }
3766 public DataGridViewHitTestType Type {
3767 get { return type; }
3770 public override bool Equals (object value) {
3771 if (value is HitTestInfo) {
3772 HitTestInfo aux = (HitTestInfo) value;
3773 if (aux.columnIndex == columnIndex && aux.columnX == columnX && aux.rowIndex == rowIndex && aux.rowY == rowY && aux.type == type) {
3780 public override int GetHashCode () {
3781 return base.GetHashCode();
3784 public override string ToString () {
3785 return GetType().Name;
3790 [ComVisibleAttribute(true)]
3791 protected class DataGridViewAccessibleObject : ControlAccessibleObject {
3793 public DataGridViewAccessibleObject (DataGridView owner) : base (owner){
3796 public override AccessibleRole Role {
3797 get { return base.Role; }
3800 public override AccessibleObject GetChild (int index) {
3801 return base.GetChild(index);
3804 public override int GetChildCount () {
3805 return base.GetChildCount();
3808 public override AccessibleObject GetFocused () {
3809 return base.GetFocused();
3812 public override AccessibleObject GetSelected () {
3813 return base.GetSelected();
3816 public override AccessibleObject HitTest (int x, int y) {
3817 return base.HitTest(x, y);
3820 public override AccessibleObject Navigate( AccessibleNavigation navigationDirection) {
3821 return base.Navigate(navigationDirection);