1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
23 // Pedro MartÃnez Juliá <pedromj@gmail.com>
29 using System.ComponentModel;
31 namespace System.Windows.Forms {
33 public class DataGridViewButtonCell : DataGridViewCell {
35 private FlatStyle flatStyle;
36 private bool useColumnTextForButtonValue;
38 public DataGridViewButtonCell () {
39 useColumnTextForButtonValue = false;
42 public override Type EditType {
46 [DefaultValue (FlatStyle.Standard)]
47 public FlatStyle FlatStyle {
48 get { return flatStyle; }
50 if (!Enum.IsDefined(typeof(FlatStyle), value)) {
51 throw new InvalidEnumArgumentException("Value is not valid FlatStyle.");
53 if (value == FlatStyle.Popup) {
54 throw new Exception("FlatStyle cannot be set to Popup in this control.");
59 public override Type FormattedValueType {
60 get { return base.FormattedValueType; }
63 [DefaultValue (false)]
64 public bool UseColumnTextForButtonValue {
65 get { return useColumnTextForButtonValue; }
66 set { useColumnTextForButtonValue = value; }
69 public override Type ValueType {
70 get { return base.ValueType; }
73 public override object Clone () {
74 DataGridViewButtonCell result = (DataGridViewButtonCell) base.Clone();
75 result.flatStyle = this.flatStyle;
76 result.useColumnTextForButtonValue = this.useColumnTextForButtonValue;
80 public override string ToString () {
81 return GetType().Name + ": RowIndex: " + RowIndex.ToString() + "; ColumnIndex: " + ColumnIndex.ToString() + ";";
84 protected override AccessibleObject CreateAccessibilityInstance () {
85 return new DataGridViewButtonCellAccessibleObject(this);
88 protected override Rectangle GetContentBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
89 throw new NotImplementedException();
92 protected override Rectangle GetErrorIconBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
93 throw new NotImplementedException();
96 protected override Size GetPreferredSize (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize) {
97 throw new NotImplementedException();
100 protected override object GetValue (int rowIndex) {
101 throw new NotImplementedException();
104 protected override bool KeyDownUnsharesRow (KeyEventArgs e, int rowIndex) {
105 // true if the user pressed the SPACE key without modifier keys; otherwise, false
106 throw new NotImplementedException();
109 protected override bool KeyUpUnsharesRow (KeyEventArgs e, int rowIndex) {
110 // true if the user released the SPACE key; otherwise false
111 throw new NotImplementedException();
115 protected override bool MouseDownUnsharesRow (DataGridViewCellMouseEventArgs e) {
116 return (e.Button == MouseButtons.Left);
119 protected override bool MouseEnterUnsharesRow (int rowIndex)
121 // true if the cell was the last cell receiving a mouse click; otherwise, false.
122 throw new NotImplementedException();
125 protected override bool MouseLeaveUnsharesRow (int rowIndex)
127 // true if the button displayed by the cell is in the pressed state; otherwise, false.
128 throw new NotImplementedException();
131 protected override bool MouseUpUnsharesRow (DataGridViewCellMouseEventArgs e)
133 // true if the mouse up was caused by the release of the left mouse button; otherwise false.
134 throw new NotImplementedException();
137 protected override void OnKeyDown (KeyEventArgs e, int rowIndex)
139 // when activated by the SPACE key, this method updates the cell's user interface
140 throw new NotImplementedException();
143 protected override void OnKeyUp (KeyEventArgs e, int rowIndex)
145 // when activated by the SPACE key, this method updates the cell's user interface
146 throw new NotImplementedException();
149 protected override void OnLeave (int rowIndex, bool throughMouseClick)
151 throw new NotImplementedException();
154 protected override void OnMouseDown (DataGridViewCellMouseEventArgs e)
156 // if activated by depresing the left mouse button, this method updates the cell's user interface
157 throw new NotImplementedException();
160 protected override void OnMouseLeave (int rowIndex)
162 // if the cell's button is not in its normal state, this method causes the cell's user interface to be updated.
163 throw new NotImplementedException();
166 protected override void OnMouseMove (DataGridViewCellMouseEventArgs e)
168 throw new NotImplementedException ();
171 protected override void OnMouseUp (DataGridViewCellMouseEventArgs e)
173 // if activated by the left mouse button, this method updates the cell's user interface
174 throw new NotImplementedException();
177 protected override void Paint (Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) {
178 throw new NotImplementedException();
181 protected class DataGridViewButtonCellAccessibleObject : DataGridViewCellAccessibleObject {
183 public DataGridViewButtonCellAccessibleObject (DataGridViewCell owner) : base(owner) {
186 public override string DefaultAction {
188 if (Owner.ReadOnly) {
197 public override void DoDefaultAction () {
198 // causes the button in the ButtonCell to be clicked
201 public override int GetChildCount () {