[EditorBrowsable (EditorBrowsableState.Advanced)]
public Control EditingControl {
get {
- if (currentCell == null || !currentCell.IsInEditMode) {
- return null;
- }
- return (Control) Activator.CreateInstance(currentCell.EditType);
+ return editingControl;
}
}
return;
if (editingControl != null) {
- // Can't use Controls.RemoveAt (editingControls), because that method
+ // Can't use Controls.Remove (editingControls), because that method
// is overriden to not remove the editing control.
- Controls.RemoveAt (Controls.IndexOf (editingControl));
+ DataGridView.DataGridViewControlCollection ctrls = Controls as DataGridView.DataGridViewControlCollection;
+ if (ctrls != null) {
+ ctrls.RemoveInternal (editingControl);
+ } else {
+ Controls.Remove (editingControl);
+ }
}
if (value != null)
- Controls.Add (editingControl);
+ Controls.Add (value);
+
+ editingControl = value;
}
}
return result;
}
+ internal DataGridViewRow GetRowInternal (int rowIndex)
+ {
+ return Rows.SharedRow (rowIndex);
+ }
+
+ internal DataGridViewCell GetCellInternal (int colIndex, int rowIndex)
+ {
+ return GetRowInternal (rowIndex).Cells.GetCellInternal (colIndex);
+ }
+
public Rectangle GetCellDisplayRectangle (int columnIndex, int rowIndex, bool cutOverflow) {
if (columnIndex < 0 || columnIndex >= columns.Count) {
throw new ArgumentOutOfRangeException("Column index is out of range.");
}
- throw new NotImplementedException();
+
+ int x = 0, y = 0, w = 0, h = 0;
+
+ if (ColumnHeadersVisible)
+ y = ColumnHeadersHeight;
+
+ if (RowHeadersVisible)
+ x = RowHeadersWidth;
+
+ for (int i = 0; i < Columns.Count; i++) {
+ if (i == columnIndex) {
+ w = columns [i].Width;
+ break;
+ }
+
+ x += columns [i].Width;
+ }
+
+ for (int i = 0; i < Rows.Count; i++) {
+ if (i == rowIndex) {
+ h = rows [i].Height;
+ break;
+ }
+
+ y += rows [i].Height;
+ }
+
+ return new Rectangle (x, y, w, h);
}
public virtual DataObject GetClipboardContent () {
public HitTestInfo HitTest (int x, int y) {
///////////////////////////////////////////////////////
+ //Console.WriteLine ("HitTest ({0}, {1})", x, y);
x += horizontalScrollingOffset;
y += verticalScrollingOffset;
int rowIndex = -1;
totalHeight += row.Height;
if (y <= totalHeight) {
rowIndex = row.Index;
+ if (rowIndex == -1) {
+ rowIndex = rows.SharedRowIndexOf (row);
+ }
break;
}
totalHeight++; // sumar el ancho de las lineas...
protected virtual void OnCellClick (DataGridViewCellEventArgs e)
{
+ DataGridViewCell cell = GetCellInternal (e.ColumnIndex, e.RowIndex);
+
+ cell.OnClickInternal (e);
+
DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellClickEvent]);
if (eh != null)
eh (this, e);
protected virtual void OnCellContentClick (DataGridViewCellEventArgs e)
{
+ DataGridViewCell cell = GetCellInternal (e.ColumnIndex, e.RowIndex);
+
+ cell.OnContentClickInternal (e);
+
DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellContentClickEvent]);
if (eh != null)
eh (this, e);
protected virtual void OnCellContentDoubleClick (DataGridViewCellEventArgs e)
{
+ DataGridViewCell cell = GetCellInternal (e.ColumnIndex, e.RowIndex);
+
+ cell.OnContentDoubleClickInternal (e);
+
DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellContentDoubleClickEvent]);
if (eh != null)
eh (this, e);
protected virtual void OnCellDoubleClick (DataGridViewCellEventArgs e)
{
+ DataGridViewCell cell = GetCellInternal (e.ColumnIndex, e.RowIndex);
+
+ cell.OnDoubleClickInternal (e);
DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellDoubleClickEvent]);
if (eh != null)
eh (this, e);
protected virtual void OnCellMouseClick (DataGridViewCellMouseEventArgs e)
{
+ DataGridViewCell cell = GetCellInternal (e.ColumnIndex, e.RowIndex);
+
+ cell.OnMouseClickInternal (e);
+
DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [CellMouseClickEvent]);
if (eh != null)
eh (this, e);
protected virtual void OnCellMouseDoubleClick (DataGridViewCellMouseEventArgs e)
{
+ DataGridViewCell cell = GetCellInternal (e.ColumnIndex, e.RowIndex);
+
+ cell.OnMouseDoubleClickInternal (e);
+
DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [CellMouseDoubleClickEvent]);
if (eh != null)
eh (this, e);
protected virtual void OnCellMouseDown (DataGridViewCellMouseEventArgs e)
{
+
+ DataGridViewCell cell = GetCellInternal (e.ColumnIndex, e.RowIndex);
+
+ cell.OnMouseDownInternal (e);
+
DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [CellMouseDownEvent]);
if (eh != null)
eh (this, e);
protected virtual void OnCellMouseEnter (DataGridViewCellEventArgs e)
{
+ DataGridViewCell cell = GetCellInternal (e.ColumnIndex, e.RowIndex);
+
+ cell.OnMouseEnterInternal (e.RowIndex);
+
DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellMouseEnterEvent]);
if (eh != null)
eh (this, e);
protected virtual void OnCellMouseLeave (DataGridViewCellEventArgs e)
{
+ DataGridViewCell cell = GetCellInternal (e.ColumnIndex, e.RowIndex);
+
+ cell.OnMouseLeaveInternal (e.RowIndex);
+
DataGridViewCellEventHandler eh = (DataGridViewCellEventHandler)(Events [CellMouseLeaveEvent]);
if (eh != null)
eh (this, e);
protected virtual void OnCellMouseMove (DataGridViewCellMouseEventArgs e)
{
+ DataGridViewCell cell = GetCellInternal (e.ColumnIndex, e.RowIndex);
+
+ cell.OnMouseMoveInternal (e);
+
DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [CellMouseMoveEvent]);
if (eh != null)
eh (this, e);
protected virtual void OnCellMouseUp (DataGridViewCellMouseEventArgs e)
{
+ DataGridViewCell cell = GetCellInternal (e.ColumnIndex, e.RowIndex);
+
+ cell.OnMouseUpInternal (e);
+
DataGridViewCellMouseEventHandler eh = (DataGridViewCellMouseEventHandler)(Events [CellMouseUpEvent]);
if (eh != null)
eh (this, e);
{
base.OnMouseClick(e);
//Console.WriteLine("Mouse: Clicks: {0}; Delta: {1}; X: {2}; Y: {3};", e.Clicks, e.Delta, e.X, e.Y);
+ HitTestInfo hit = HitTest (e.X, e.Y);
+
+ switch (hit.Type)
+ {
+ case DataGridViewHitTestType.Cell:
+ Rectangle display = GetCellDisplayRectangle (hit.ColumnIndex, hit.RowIndex, false);
+ OnCellMouseClick (new DataGridViewCellMouseEventArgs (hit.ColumnIndex, hit.RowIndex, e.X - display.X, e.Y - display.Y, e));
+ break;
+
+ }
}
protected override void OnMouseDoubleClick (MouseEventArgs e)
if (hitTest.RowIndex < 0 || hitTest.ColumnIndex < 0) {
return;
}
+ Rectangle cellBounds = GetCellDisplayRectangle (hitTest.ColumnIndex, hitTest.RowIndex, false);
+ OnCellMouseDown (new DataGridViewCellMouseEventArgs (hitTest.ColumnIndex, hitTest.RowIndex, e.X - cellBounds.X, e.Y - cellBounds.Y, e));
OnCellClick(new DataGridViewCellEventArgs(hitTest.ColumnIndex, hitTest.RowIndex));
DataGridViewRow row = rows[hitTest.RowIndex];
DataGridViewCell cell = row.Cells[hitTest.ColumnIndex];
protected override void OnMouseMove (MouseEventArgs e)
{
base.OnMouseMove(e);
+ HitTestInfo hit = this.HitTest (e.X, e.Y);
+
+ switch (hit.Type)
+ {
+ case DataGridViewHitTestType.Cell:
+ Rectangle display = GetCellDisplayRectangle (hit.ColumnIndex, hit.RowIndex, false);
+ OnCellMouseMove (new DataGridViewCellMouseEventArgs (hit.ColumnIndex, hit.RowIndex, e.X - display.X, e.Y - display.Y, e));
+ break;
+ case DataGridViewHitTestType.ColumnHeader:
+ case DataGridViewHitTestType.RowHeader:
+ case DataGridViewHitTestType.TopLeftHeader:
+
+ case DataGridViewHitTestType.HorizontalScrollBar:
+ case DataGridViewHitTestType.VerticalScrollBar:
+
+
+ case DataGridViewHitTestType.None:
+ break;
+ }
}
protected override void OnMouseUp (MouseEventArgs e)
if (cell.ColumnIndex == col.Index) {
bounds.Width = col.Width;
cell.SetSize(new Size(bounds.Width, bounds.Height));
- DataGridViewCellStyle style = cell.InheritedStyle;
- if (cell == currentCell && cell.IsInEditMode) {
- cell.InitializeEditingControl(cell.RowIndex, cell.FormattedValue, style);
- cell.PositionEditingControl(true, true, bounds, e.ClipRectangle, style, false, false, (columns[currentCell.ColumnIndex].DisplayIndex == 0), (currentCell.RowIndex == 0));
+ DataGridViewCellStyle style;
+ if (cell.RowIndex == -1) {
+ style = DefaultCellStyle;
+ } else {
+ style = cell.InheritedStyle;
}
- else {
+ if (cell == currentCell && cell.IsInEditMode) {
+ Type editType = cell.EditType;
+ if (editType != null) {
+ bool isCorrectType = EditingControlInternal != null && EditingControlInternal.GetType () == editType;
+ if (EditingControlInternal != null && !isCorrectType) {
+ EditingControlInternal = null;
+ }
+ if (EditingControlInternal == null)
+ EditingControlInternal = (Control) Activator.CreateInstance (editType);
+ cell.InitializeEditingControl(cell.RowIndex, cell.FormattedValue, style);
+ cell.PositionEditingControl(true, true, bounds, e.ClipRectangle, style, false, false, (columns[currentCell.ColumnIndex].DisplayIndex == 0), (currentCell.RowIndex == 0));
+ EditingControl.Visible = true;
+ }
+ } else {
+ object value, formattedValue; string errorText;
+ if (cell.RowIndex == -1) {
+ // TODO: Look up value if databound.
+ value = null; formattedValue = null; errorText = null;
+ } else {
+ value = cell.Value; formattedValue = cell.FormattedValue; errorText = cell.ErrorText;
+ }
DataGridViewAdvancedBorderStyle intermediateBorderStyle = (DataGridViewAdvancedBorderStyle) ((ICloneable)this.AdvancedCellBorderStyle).Clone();
DataGridViewAdvancedBorderStyle borderStyle = cell.AdjustCellBorderStyle(this.AdvancedCellBorderStyle, intermediateBorderStyle, true, true, j == 0, cell.RowIndex == 0);
- OnCellFormatting(new DataGridViewCellFormattingEventArgs(cell.ColumnIndex, cell.RowIndex, cell.Value, cell.FormattedValueType, style));
- 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);
+ OnCellFormatting(new DataGridViewCellFormattingEventArgs(cell.ColumnIndex, cell.RowIndex, value, cell.FormattedValueType, style));
+ DataGridViewCellPaintingEventArgs args = new DataGridViewCellPaintingEventArgs (this, e.Graphics, e.ClipRectangle, bounds, cell.RowIndex, cell.ColumnIndex, cell.State, value, formattedValue, errorText, style, borderStyle, DataGridViewPaintParts.All);
OnCellPainting(args);
if (!args.Handled) {
- cell.InternalPaint(e.Graphics, e.ClipRectangle, bounds, cell.RowIndex, cell.State, cell.Value, cell.FormattedValue, cell.ErrorText, style, borderStyle, DataGridViewPaintParts.All);
+ cell.InternalPaint(e.Graphics, e.ClipRectangle, bounds, cell.RowIndex, cell.State, value, formattedValue, errorText, style, borderStyle, DataGridViewPaintParts.All);
}
}
bounds.X += bounds.Width;
base.Remove (value);
}
+ internal void RemoveInternal (Control value)
+ {
+ base.Remove (value);
+ }
+
}
}
public int ColumnIndex {
- get { return columnIndex; }
+ get {
+ if (DataGridView == null)
+ return -1;
+ return columnIndex;
+ }
}
[Browsable (false)]
public Rectangle ContentBounds {
- get { return contentBounds; }
+ get {
+ return GetContentBounds (RowIndex);
+ }
}
[DefaultValue (null)]
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Advanced)]
public object EditedFormattedValue {
- get { return editedFormattedValue; }
+ get {
+ return GetEditedFormattedValue (RowIndex, DataGridViewDataErrorContexts.Formatting);
+ }
}
[Browsable (false)]
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Advanced)]
public Rectangle ErrorIconBounds {
- get { return errorIconBounds; }
+ get {
+ DataGridViewCellStyle style = InheritedStyle;
+ return errorIconBounds;
+ }
}
[Browsable (false)]
public string ErrorText {
- get { return errorText; }
+ get {
+ if (errorText == null)
+ return string.Empty;
+
+ return errorText;
+ }
set {
if (errorText != value) {
errorText = value;
[Browsable (false)]
public object FormattedValue {
get {
+ if (DataGridView == null)
+ return null;
+
DataGridViewCellStyle style = InheritedStyle;
if (style.Format != String.Empty && FormattedValueType == typeof(string)) {
return String.Format("{0:" + style.Format + "}", Value);
[Browsable (false)]
public DataGridViewElementStates InheritedState {
- get { return inheritedState; }
+ get {
+ return GetInheritedState (RowIndex);
+ }
}
[Browsable (false)]
public DataGridViewCellStyle InheritedStyle {
get {
- DataGridViewCellStyle result = new DataGridViewCellStyle();
- if (style != null && style.Alignment != DataGridViewContentAlignment.NotSet) {
- result.Alignment = style.Alignment;
- }
- else if (OwningRow != null && OwningRow.DefaultCellStyle.Alignment != DataGridViewContentAlignment.NotSet) {
- result.Alignment = OwningRow.DefaultCellStyle.Alignment;
- }
- else if (DataGridView != null) {
- if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.Alignment != DataGridViewContentAlignment.NotSet) {
- result.Alignment = DataGridView.AlternatingRowsDefaultCellStyle.Alignment;
- }
- else if (DataGridView.RowsDefaultCellStyle.Alignment != DataGridViewContentAlignment.NotSet) {
- result.Alignment = DataGridView.RowsDefaultCellStyle.Alignment;
- }
- else if (ColumnIndex >= 0 && DataGridView.Columns[ColumnIndex].DefaultCellStyle.Alignment != DataGridViewContentAlignment.NotSet) {
- result.Alignment = DataGridView.Columns[ColumnIndex].DefaultCellStyle.Alignment;
- }
- else {
- result.Alignment = DataGridView.DefaultCellStyle.Alignment;
- }
- }
- if (style != null && style.BackColor != Color.Empty) {
- result.BackColor = style.BackColor;
- }
- else if (OwningRow != null && OwningRow.DefaultCellStyle.BackColor != Color.Empty) {
- result.BackColor = OwningRow.DefaultCellStyle.BackColor;
- }
- else if (DataGridView != null) {
- if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.BackColor != Color.Empty) {
- result.BackColor = DataGridView.AlternatingRowsDefaultCellStyle.BackColor;
- }
- else if (DataGridView.RowsDefaultCellStyle.BackColor != Color.Empty) {
- result.BackColor = DataGridView.RowsDefaultCellStyle.BackColor;
- }
- else if (ColumnIndex >= 0 && DataGridView.Columns[ColumnIndex].DefaultCellStyle.BackColor != Color.Empty) {
- result.BackColor = DataGridView.Columns[ColumnIndex].DefaultCellStyle.BackColor;
- }
- else {
- result.BackColor = DataGridView.DefaultCellStyle.BackColor;
- }
- }
- if (style != null && style.Font != null) {
- result.Font = style.Font;
- }
- else if (OwningRow != null && OwningRow.DefaultCellStyle.Font != null) {
- result.Font = OwningRow.DefaultCellStyle.Font;
- }
- else if (DataGridView != null) {
- if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.Font != null) {
- result.Font = DataGridView.AlternatingRowsDefaultCellStyle.Font;
- }
- else if (DataGridView.RowsDefaultCellStyle.Font != null) {
- result.Font = DataGridView.RowsDefaultCellStyle.Font;
- }
- else if (ColumnIndex >= 0 && DataGridView.Columns[ColumnIndex].DefaultCellStyle.Font != null) {
- result.Font = DataGridView.Columns[ColumnIndex].DefaultCellStyle.Font;
- }
- else {
- result.Font = DataGridView.DefaultCellStyle.Font;
- }
- }
- if (style != null && style.ForeColor != Color.Empty) {
- result.ForeColor = style.ForeColor;
- }
- else if (OwningRow != null && OwningRow.DefaultCellStyle.ForeColor != Color.Empty) {
- result.ForeColor = OwningRow.DefaultCellStyle.ForeColor;
- }
- else if (DataGridView != null) {
- if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.ForeColor != Color.Empty) {
- result.ForeColor = DataGridView.AlternatingRowsDefaultCellStyle.ForeColor;
- }
- else if (DataGridView.RowsDefaultCellStyle.ForeColor != Color.Empty) {
- result.ForeColor = DataGridView.RowsDefaultCellStyle.ForeColor;
- }
- else if (ColumnIndex >= 0 && DataGridView.Columns[ColumnIndex].DefaultCellStyle.ForeColor != Color.Empty) {
- result.ForeColor = DataGridView.Columns[ColumnIndex].DefaultCellStyle.ForeColor;
- }
- else {
- result.ForeColor = DataGridView.DefaultCellStyle.ForeColor;
- }
- }
- if (style != null && style.Format != String.Empty) {
- result.Format = style.Format;
- }
- else if (OwningRow != null && OwningRow.DefaultCellStyle.Format != String.Empty) {
- result.Format = OwningRow.DefaultCellStyle.Format;
- }
- else if (DataGridView != null) {
- if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.Format != String.Empty) {
- result.Format = DataGridView.AlternatingRowsDefaultCellStyle.Format;
- }
- else if (DataGridView.RowsDefaultCellStyle.Format != String.Empty) {
- result.Format = DataGridView.RowsDefaultCellStyle.Format;
- }
- else if (ColumnIndex >= 0 && DataGridView.Columns[ColumnIndex].DefaultCellStyle.Format != String.Empty) {
- result.Format = DataGridView.Columns[ColumnIndex].DefaultCellStyle.Format;
- }
- else {
- result.Format = DataGridView.DefaultCellStyle.Format;
- }
- }
- if (style != null && style.FormatProvider != System.Globalization.CultureInfo.CurrentUICulture) {
- result.FormatProvider = style.FormatProvider;
- }
- else if (OwningRow != null && OwningRow.DefaultCellStyle.FormatProvider != System.Globalization.CultureInfo.CurrentUICulture) {
- result.FormatProvider = OwningRow.DefaultCellStyle.FormatProvider;
- }
- else if (DataGridView != null) {
- if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.FormatProvider != System.Globalization.CultureInfo.CurrentUICulture) {
- result.FormatProvider = DataGridView.AlternatingRowsDefaultCellStyle.FormatProvider;
- }
- else if (DataGridView.RowsDefaultCellStyle.FormatProvider != System.Globalization.CultureInfo.CurrentUICulture) {
- result.FormatProvider = DataGridView.RowsDefaultCellStyle.FormatProvider;
- }
- else if (ColumnIndex >= 0 && DataGridView.Columns[ColumnIndex].DefaultCellStyle.FormatProvider != System.Globalization.CultureInfo.CurrentUICulture) {
- result.FormatProvider = DataGridView.Columns[ColumnIndex].DefaultCellStyle.FormatProvider;
- }
- else {
- result.FormatProvider = DataGridView.DefaultCellStyle.FormatProvider;
- }
- }
- if (style != null && (string) style.NullValue != "(null)") {
- result.NullValue = style.NullValue;
- }
- else if (OwningRow != null && (string) OwningRow.DefaultCellStyle.NullValue != "(null)") {
- result.NullValue = OwningRow.DefaultCellStyle.NullValue;
- }
- else if (DataGridView != null) {
- if ((RowIndex % 2) == 1 && (string) DataGridView.AlternatingRowsDefaultCellStyle.NullValue != "(null)") {
- result.NullValue = DataGridView.AlternatingRowsDefaultCellStyle.NullValue;
- }
- else if ((string) DataGridView.RowsDefaultCellStyle.NullValue != "(null)") {
- result.NullValue = DataGridView.RowsDefaultCellStyle.NullValue;
- }
- else if (ColumnIndex >= 0 && (string) DataGridView.Columns[ColumnIndex].DefaultCellStyle.NullValue != "(null)") {
- result.NullValue = DataGridView.Columns[ColumnIndex].DefaultCellStyle.NullValue;
- }
- else {
- result.NullValue = DataGridView.DefaultCellStyle.NullValue;
- }
- }
- if (style != null && style.Padding != Padding.Empty) {
- result.Padding = style.Padding;
- }
- else if (OwningRow != null && OwningRow.DefaultCellStyle.Padding != Padding.Empty) {
- result.Padding = OwningRow.DefaultCellStyle.Padding;
- }
- else if (DataGridView != null) {
- if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.Padding != Padding.Empty) {
- result.Padding = DataGridView.AlternatingRowsDefaultCellStyle.Padding;
- }
- else if (DataGridView.RowsDefaultCellStyle.Padding != Padding.Empty) {
- result.Padding = DataGridView.RowsDefaultCellStyle.Padding;
- }
- else if (ColumnIndex >= 0 && DataGridView.Columns[ColumnIndex].DefaultCellStyle.Padding != Padding.Empty) {
- result.Padding = DataGridView.Columns[ColumnIndex].DefaultCellStyle.Padding;
- }
- else {
- result.Padding = DataGridView.DefaultCellStyle.Padding;
- }
- }
- if (style != null && style.SelectionBackColor != Color.Empty) {
- result.SelectionBackColor = style.SelectionBackColor;
- }
- else if (OwningRow != null && OwningRow.DefaultCellStyle.SelectionBackColor != Color.Empty) {
- result.SelectionBackColor = OwningRow.DefaultCellStyle.SelectionBackColor;
- }
- else if (DataGridView != null) {
- if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.SelectionBackColor != Color.Empty) {
- result.SelectionBackColor = DataGridView.AlternatingRowsDefaultCellStyle.SelectionBackColor;
- }
- else if (DataGridView.RowsDefaultCellStyle.SelectionBackColor != Color.Empty) {
- result.SelectionBackColor = DataGridView.RowsDefaultCellStyle.SelectionBackColor;
- }
- else if (ColumnIndex >= 0 && DataGridView.Columns[ColumnIndex].DefaultCellStyle.SelectionBackColor != Color.Empty) {
- result.SelectionBackColor = DataGridView.Columns[ColumnIndex].DefaultCellStyle.SelectionBackColor;
- }
- else {
- result.SelectionBackColor = DataGridView.DefaultCellStyle.SelectionBackColor;
- }
- }
- if (style != null && style.SelectionForeColor != Color.Empty) {
- result.SelectionForeColor = style.SelectionForeColor;
- }
- else if (OwningRow != null && OwningRow.DefaultCellStyle.SelectionForeColor != Color.Empty) {
- result.SelectionForeColor = OwningRow.DefaultCellStyle.SelectionForeColor;
- }
- else if (DataGridView != null) {
- if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.SelectionForeColor != Color.Empty) {
- result.SelectionForeColor = DataGridView.AlternatingRowsDefaultCellStyle.SelectionForeColor;
- }
- else if (DataGridView.RowsDefaultCellStyle.SelectionForeColor != Color.Empty) {
- result.SelectionForeColor = DataGridView.RowsDefaultCellStyle.SelectionForeColor;
- }
- else if (ColumnIndex >= 0 && DataGridView.Columns[ColumnIndex].DefaultCellStyle.SelectionForeColor != Color.Empty) {
- result.SelectionForeColor = DataGridView.Columns[ColumnIndex].DefaultCellStyle.SelectionForeColor;
- }
- else {
- result.SelectionForeColor = DataGridView.DefaultCellStyle.SelectionForeColor;
- }
- }
- if (style != null && style.Tag != null) {
- result.Tag = style.Tag;
- }
- else if (OwningRow != null && OwningRow.DefaultCellStyle.Tag != null) {
- result.Tag = OwningRow.DefaultCellStyle.Tag;
- }
- else if (DataGridView != null) {
- if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.Tag != null) {
- result.Tag = DataGridView.AlternatingRowsDefaultCellStyle.Tag;
- }
- else if (DataGridView.RowsDefaultCellStyle.Tag != null) {
- result.Tag = DataGridView.RowsDefaultCellStyle.Tag;
- }
- else if (ColumnIndex >= 0 && DataGridView.Columns[ColumnIndex].DefaultCellStyle.Tag != null) {
- result.Tag = DataGridView.Columns[ColumnIndex].DefaultCellStyle.Tag;
- }
- else {
- result.Tag = DataGridView.DefaultCellStyle.Tag;
- }
- }
- if (style != null && style.WrapMode != DataGridViewTriState.NotSet) {
- result.WrapMode = style.WrapMode;
- }
- else if (OwningRow != null && OwningRow.DefaultCellStyle.WrapMode != DataGridViewTriState.NotSet) {
- result.WrapMode = OwningRow.DefaultCellStyle.WrapMode;
- }
- else if (DataGridView != null) {
- if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.WrapMode != DataGridViewTriState.NotSet) {
- result.WrapMode = DataGridView.AlternatingRowsDefaultCellStyle.WrapMode;
- }
- else if (DataGridView.RowsDefaultCellStyle.WrapMode != DataGridViewTriState.NotSet) {
- result.WrapMode = DataGridView.RowsDefaultCellStyle.WrapMode;
- }
- else if (ColumnIndex >= 0 && DataGridView.Columns[ColumnIndex].DefaultCellStyle.WrapMode != DataGridViewTriState.NotSet) {
- result.WrapMode = DataGridView.Columns[ColumnIndex].DefaultCellStyle.WrapMode;
- }
- else {
- result.WrapMode = DataGridView.DefaultCellStyle.WrapMode;
- }
- }
- return result;
+ return GetInheritedStyle (null, RowIndex, true);
}
}
[Browsable (false)]
public bool IsInEditMode {
- get { return isInEditMode; }
+ get {
+ if (DataGridView == null)
+ return false;
+
+ if (RowIndex == -1)
+ throw new InvalidOperationException ("Operation cannot be performed on a cell of a shared row.");
+
+ return isInEditMode;
+ }
}
[Browsable (false)]
[Browsable (false)]
public Size PreferredSize {
- get { return preferredSize; }
+ get {
+ if (DataGridView == null)
+ return Size.Empty;
+
+ return GetPreferredSize (Hwnd.bmp_g, InheritedStyle, RowIndex, Size.Empty);
+ }
}
[Browsable (false)]
[Browsable (false)]
public virtual bool Resizable {
- get { return resizable; }
+ get {
+ return resizable;
+ }
}
[Browsable (false)]
[Browsable (false)]
public Size Size {
- get { return size; }
+ get {
+ if (DataGridView == null)
+ return Size.Empty;
+
+ if (RowIndex == -1)
+ throw new InvalidOperationException ("Getting the Size property of a cell in a shared row is not a valid operation.");
+
+ return GetSize (RowIndex);
+ }
}
[Browsable (true)]
public DataGridViewCellStyle Style {
get {
- if (style != null) {
+ if (style == null) {
style = new DataGridViewCellStyle();
style.StyleChanged += OnStyleChanged;
}
[Browsable (false)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public string ToolTipText {
- get { return toolTipText; }
+ get { return toolTipText == null ? string.Empty : toolTipText; }
set { toolTipText = value; }
}
[Browsable (false)]
public object Value {
- get { return valuex; }
+ get {
+ return GetValue (RowIndex);
+ }
set {
- if (valuex != value) {
- valuex = value;
- RaiseCellValueChanged(new DataGridViewCellEventArgs(ColumnIndex, RowIndex));
- }
+ SetValue (RowIndex, value);
}
}
[Browsable (false)]
public virtual bool Visible {
- get { return visible; }
+ get {
+ // This is independent from State...
+ DataGridViewColumn col = OwningColumn;
+ DataGridViewRow row = OwningRow;
+
+ bool rowVisible = true, colVisible = true;
+
+ if (row == null && col == null)
+ return false;
+
+ if (row != null) {
+ rowVisible = !row.IsShared && row.Visible;
+ }
+
+ if (col != null) {
+ colVisible = col.Index >= 0 && col.Visible;
+ }
+
+ return rowVisible && colVisible;
+ }
}
[EditorBrowsable (EditorBrowsableState.Advanced)]
}
public virtual object Clone () {
- return this.MemberwiseClone();
- /*
- DataGridViewCell result = null; // = new DataGridViewCell();
+ DataGridViewCell result = (DataGridViewCell) Activator.CreateInstance (GetType ());
result.accessibilityObject = this.accessibilityObject;
result.columnIndex = this.columnIndex;
result.contentBounds = this.contentBounds;
result.errorText = this.errorText;
result.formattedValueType = this.formattedValueType;
result.frozen = this.frozen;
- result.hasStyle = this.hasStyle;
result.inheritedState = this.inheritedState;
- result.inheritedStyle = this.inheritedStyle;
result.isInEditMode = this.isInEditMode;
result.owningColumn = this.owningColumn;
result.owningRow = this.owningRow;
result.valueType = this.valueType;
result.visible = this.visible;
return result;
- */
}
[EditorBrowsable (EditorBrowsableState.Advanced)]
}
public Rectangle GetContentBounds (int rowIndex) {
- throw new NotImplementedException();
+ if (DataGridView == null)
+ return Rectangle.Empty;
+
+ return GetContentBounds (Hwnd.bmp_g, InheritedStyle, rowIndex);
}
public object GetEditedFormattedValue (int rowIndex, DataGridViewDataErrorContexts context) {
- throw new NotImplementedException();
+ if (DataGridView == null)
+ return null;
+
+ DataGridViewCellStyle style = InheritedStyle;
+
+ return editedFormattedValue;
}
public virtual ContextMenuStrip GetInheritedContextMenuStrip (int rowIndex)
}
public virtual DataGridViewElementStates GetInheritedState (int rowIndex) {
- throw new NotImplementedException();
+
+ if (DataGridView == null && rowIndex != -1)
+ throw new ArgumentException ("msg?");
+
+ if (DataGridView != null && (rowIndex < 0 || rowIndex >= DataGridView.Rows.Count))
+ throw new ArgumentOutOfRangeException ("rowIndex", "Specified argument was out of the range of valid values.");
+
+ DataGridViewElementStates result;
+
+ result = DataGridViewElementStates.ResizableSet;
+
+ DataGridViewColumn col = OwningColumn;
+ DataGridViewRow row = OwningRow;
+
+ if (DataGridView == null) {
+ if (row != null) {
+ if (row.Resizable == DataGridViewTriState.True)
+ result |= DataGridViewElementStates.Resizable;
+
+ if (row.Visible)
+ result |= DataGridViewElementStates.Visible;
+
+ if (row.ReadOnly)
+ result |= DataGridViewElementStates.ReadOnly;
+
+ if (row.Frozen)
+ result |= DataGridViewElementStates.Frozen;
+
+ if (row.Displayed)
+ result |= DataGridViewElementStates.Displayed;
+
+ /*if (row.Selected)
+ result |= DataGridViewElementStates.Selected;*/
+ }
+
+ return result;
+ }
+
+ if (col.Resizable == DataGridViewTriState.True && row.Resizable == DataGridViewTriState.True)
+ result |= DataGridViewElementStates.Resizable;
+
+ if (col.Visible && row.Visible)
+ result |= DataGridViewElementStates.Visible;
+
+ if (col.ReadOnly && row.ReadOnly)
+ result |= DataGridViewElementStates.ReadOnly;
+
+ if (col.Frozen && row.Frozen)
+ result |= DataGridViewElementStates.Frozen;
+
+ if (col.Displayed && row.Displayed)
+ result |= DataGridViewElementStates.Displayed;
+
+ if (col.Selected && row.Selected)
+ result |= DataGridViewElementStates.Selected;
+
+ return result;
}
public virtual DataGridViewCellStyle GetInheritedStyle (DataGridViewCellStyle inheritedCellStyle, int rowIndex, bool includeColors) {
* System.InvalidOperationException :: The cell has no associated System.Windows.Forms.DataGridView, or the cell's System.Windows.Forms.DataGridViewCell.ColumnIndex is less than 0.
* System.ArgumentOutOfRangeException :: rowIndex is less than 0, or greater than or equal to the number of rows in the parent System.Windows.Forms.DataGridView.
* */
- throw new NotImplementedException();
+
+ if (DataGridView == null)
+ throw new InvalidOperationException ("Cell is not in a DataGridView. The cell cannot retrieve the inherited cell style.");
+
+ if (rowIndex < 0 || rowIndex >= DataGridView.Rows.Count)
+ throw new ArgumentOutOfRangeException ("rowIndex", "Specified argument was out of the range of valid values.");
+
+ DataGridViewCellStyle result = new DataGridViewCellStyle ();
+ if (style != null && style.Alignment != DataGridViewContentAlignment.NotSet) {
+ result.Alignment = style.Alignment;
+ } else if (OwningRow != null && OwningRow.DefaultCellStyle.Alignment != DataGridViewContentAlignment.NotSet) {
+ result.Alignment = OwningRow.DefaultCellStyle.Alignment;
+ } else if (DataGridView != null) {
+ if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.Alignment != DataGridViewContentAlignment.NotSet) {
+ result.Alignment = DataGridView.AlternatingRowsDefaultCellStyle.Alignment;
+ } else if (DataGridView.RowsDefaultCellStyle.Alignment != DataGridViewContentAlignment.NotSet) {
+ result.Alignment = DataGridView.RowsDefaultCellStyle.Alignment;
+ } else if (ColumnIndex >= 0 && DataGridView.Columns [ColumnIndex].DefaultCellStyle.Alignment != DataGridViewContentAlignment.NotSet) {
+ result.Alignment = DataGridView.Columns [ColumnIndex].DefaultCellStyle.Alignment;
+ } else {
+ result.Alignment = DataGridView.DefaultCellStyle.Alignment;
+ }
+ }
+ if (style != null && style.BackColor != Color.Empty) {
+ result.BackColor = style.BackColor;
+ } else if (OwningRow != null && OwningRow.DefaultCellStyle.BackColor != Color.Empty) {
+ result.BackColor = OwningRow.DefaultCellStyle.BackColor;
+ } else if (DataGridView != null) {
+ if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.BackColor != Color.Empty) {
+ result.BackColor = DataGridView.AlternatingRowsDefaultCellStyle.BackColor;
+ } else if (DataGridView.RowsDefaultCellStyle.BackColor != Color.Empty) {
+ result.BackColor = DataGridView.RowsDefaultCellStyle.BackColor;
+ } else if (ColumnIndex >= 0 && DataGridView.Columns [ColumnIndex].DefaultCellStyle.BackColor != Color.Empty) {
+ result.BackColor = DataGridView.Columns [ColumnIndex].DefaultCellStyle.BackColor;
+ } else {
+ result.BackColor = DataGridView.DefaultCellStyle.BackColor;
+ }
+ }
+ if (style != null && style.Font != null) {
+ result.Font = style.Font;
+ } else if (OwningRow != null && OwningRow.DefaultCellStyle.Font != null) {
+ result.Font = OwningRow.DefaultCellStyle.Font;
+ } else if (DataGridView != null) {
+ if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.Font != null) {
+ result.Font = DataGridView.AlternatingRowsDefaultCellStyle.Font;
+ } else if (DataGridView.RowsDefaultCellStyle.Font != null) {
+ result.Font = DataGridView.RowsDefaultCellStyle.Font;
+ } else if (ColumnIndex >= 0 && DataGridView.Columns [ColumnIndex].DefaultCellStyle.Font != null) {
+ result.Font = DataGridView.Columns [ColumnIndex].DefaultCellStyle.Font;
+ } else {
+ result.Font = DataGridView.DefaultCellStyle.Font;
+ }
+ }
+ if (style != null && style.ForeColor != Color.Empty) {
+ result.ForeColor = style.ForeColor;
+ } else if (OwningRow != null && OwningRow.DefaultCellStyle.ForeColor != Color.Empty) {
+ result.ForeColor = OwningRow.DefaultCellStyle.ForeColor;
+ } else if (DataGridView != null) {
+ if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.ForeColor != Color.Empty) {
+ result.ForeColor = DataGridView.AlternatingRowsDefaultCellStyle.ForeColor;
+ } else if (DataGridView.RowsDefaultCellStyle.ForeColor != Color.Empty) {
+ result.ForeColor = DataGridView.RowsDefaultCellStyle.ForeColor;
+ } else if (ColumnIndex >= 0 && DataGridView.Columns [ColumnIndex].DefaultCellStyle.ForeColor != Color.Empty) {
+ result.ForeColor = DataGridView.Columns [ColumnIndex].DefaultCellStyle.ForeColor;
+ } else {
+ result.ForeColor = DataGridView.DefaultCellStyle.ForeColor;
+ }
+ }
+ if (style != null && style.Format != String.Empty) {
+ result.Format = style.Format;
+ } else if (OwningRow != null && OwningRow.DefaultCellStyle.Format != String.Empty) {
+ result.Format = OwningRow.DefaultCellStyle.Format;
+ } else if (DataGridView != null) {
+ if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.Format != String.Empty) {
+ result.Format = DataGridView.AlternatingRowsDefaultCellStyle.Format;
+ } else if (DataGridView.RowsDefaultCellStyle.Format != String.Empty) {
+ result.Format = DataGridView.RowsDefaultCellStyle.Format;
+ } else if (ColumnIndex >= 0 && DataGridView.Columns [ColumnIndex].DefaultCellStyle.Format != String.Empty) {
+ result.Format = DataGridView.Columns [ColumnIndex].DefaultCellStyle.Format;
+ } else {
+ result.Format = DataGridView.DefaultCellStyle.Format;
+ }
+ }
+ if (style != null && style.FormatProvider != System.Globalization.CultureInfo.CurrentUICulture) {
+ result.FormatProvider = style.FormatProvider;
+ } else if (OwningRow != null && OwningRow.DefaultCellStyle.FormatProvider != System.Globalization.CultureInfo.CurrentUICulture) {
+ result.FormatProvider = OwningRow.DefaultCellStyle.FormatProvider;
+ } else if (DataGridView != null) {
+ if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.FormatProvider != System.Globalization.CultureInfo.CurrentUICulture) {
+ result.FormatProvider = DataGridView.AlternatingRowsDefaultCellStyle.FormatProvider;
+ } else if (DataGridView.RowsDefaultCellStyle.FormatProvider != System.Globalization.CultureInfo.CurrentUICulture) {
+ result.FormatProvider = DataGridView.RowsDefaultCellStyle.FormatProvider;
+ } else if (ColumnIndex >= 0 && DataGridView.Columns [ColumnIndex].DefaultCellStyle.FormatProvider != System.Globalization.CultureInfo.CurrentUICulture) {
+ result.FormatProvider = DataGridView.Columns [ColumnIndex].DefaultCellStyle.FormatProvider;
+ } else {
+ result.FormatProvider = DataGridView.DefaultCellStyle.FormatProvider;
+ }
+ }
+ if (style != null && (string)style.NullValue != "(null)") {
+ result.NullValue = style.NullValue;
+ } else if (OwningRow != null && (string)OwningRow.DefaultCellStyle.NullValue != "(null)") {
+ result.NullValue = OwningRow.DefaultCellStyle.NullValue;
+ } else if (DataGridView != null) {
+ if ((RowIndex % 2) == 1 && (string)DataGridView.AlternatingRowsDefaultCellStyle.NullValue != "(null)") {
+ result.NullValue = DataGridView.AlternatingRowsDefaultCellStyle.NullValue;
+ } else if ((string)DataGridView.RowsDefaultCellStyle.NullValue != "(null)") {
+ result.NullValue = DataGridView.RowsDefaultCellStyle.NullValue;
+ } else if (ColumnIndex >= 0 && (string)DataGridView.Columns [ColumnIndex].DefaultCellStyle.NullValue != "(null)") {
+ result.NullValue = DataGridView.Columns [ColumnIndex].DefaultCellStyle.NullValue;
+ } else {
+ result.NullValue = DataGridView.DefaultCellStyle.NullValue;
+ }
+ }
+ if (style != null && style.Padding != Padding.Empty) {
+ result.Padding = style.Padding;
+ } else if (OwningRow != null && OwningRow.DefaultCellStyle.Padding != Padding.Empty) {
+ result.Padding = OwningRow.DefaultCellStyle.Padding;
+ } else if (DataGridView != null) {
+ if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.Padding != Padding.Empty) {
+ result.Padding = DataGridView.AlternatingRowsDefaultCellStyle.Padding;
+ } else if (DataGridView.RowsDefaultCellStyle.Padding != Padding.Empty) {
+ result.Padding = DataGridView.RowsDefaultCellStyle.Padding;
+ } else if (ColumnIndex >= 0 && DataGridView.Columns [ColumnIndex].DefaultCellStyle.Padding != Padding.Empty) {
+ result.Padding = DataGridView.Columns [ColumnIndex].DefaultCellStyle.Padding;
+ } else {
+ result.Padding = DataGridView.DefaultCellStyle.Padding;
+ }
+ }
+ if (style != null && style.SelectionBackColor != Color.Empty) {
+ result.SelectionBackColor = style.SelectionBackColor;
+ } else if (OwningRow != null && OwningRow.DefaultCellStyle.SelectionBackColor != Color.Empty) {
+ result.SelectionBackColor = OwningRow.DefaultCellStyle.SelectionBackColor;
+ } else if (DataGridView != null) {
+ if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.SelectionBackColor != Color.Empty) {
+ result.SelectionBackColor = DataGridView.AlternatingRowsDefaultCellStyle.SelectionBackColor;
+ } else if (DataGridView.RowsDefaultCellStyle.SelectionBackColor != Color.Empty) {
+ result.SelectionBackColor = DataGridView.RowsDefaultCellStyle.SelectionBackColor;
+ } else if (ColumnIndex >= 0 && DataGridView.Columns [ColumnIndex].DefaultCellStyle.SelectionBackColor != Color.Empty) {
+ result.SelectionBackColor = DataGridView.Columns [ColumnIndex].DefaultCellStyle.SelectionBackColor;
+ } else {
+ result.SelectionBackColor = DataGridView.DefaultCellStyle.SelectionBackColor;
+ }
+ }
+ if (style != null && style.SelectionForeColor != Color.Empty) {
+ result.SelectionForeColor = style.SelectionForeColor;
+ } else if (OwningRow != null && OwningRow.DefaultCellStyle.SelectionForeColor != Color.Empty) {
+ result.SelectionForeColor = OwningRow.DefaultCellStyle.SelectionForeColor;
+ } else if (DataGridView != null) {
+ if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.SelectionForeColor != Color.Empty) {
+ result.SelectionForeColor = DataGridView.AlternatingRowsDefaultCellStyle.SelectionForeColor;
+ } else if (DataGridView.RowsDefaultCellStyle.SelectionForeColor != Color.Empty) {
+ result.SelectionForeColor = DataGridView.RowsDefaultCellStyle.SelectionForeColor;
+ } else if (ColumnIndex >= 0 && DataGridView.Columns [ColumnIndex].DefaultCellStyle.SelectionForeColor != Color.Empty) {
+ result.SelectionForeColor = DataGridView.Columns [ColumnIndex].DefaultCellStyle.SelectionForeColor;
+ } else {
+ result.SelectionForeColor = DataGridView.DefaultCellStyle.SelectionForeColor;
+ }
+ }
+ if (style != null && style.Tag != null) {
+ result.Tag = style.Tag;
+ } else if (OwningRow != null && OwningRow.DefaultCellStyle.Tag != null) {
+ result.Tag = OwningRow.DefaultCellStyle.Tag;
+ } else if (DataGridView != null) {
+ if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.Tag != null) {
+ result.Tag = DataGridView.AlternatingRowsDefaultCellStyle.Tag;
+ } else if (DataGridView.RowsDefaultCellStyle.Tag != null) {
+ result.Tag = DataGridView.RowsDefaultCellStyle.Tag;
+ } else if (ColumnIndex >= 0 && DataGridView.Columns [ColumnIndex].DefaultCellStyle.Tag != null) {
+ result.Tag = DataGridView.Columns [ColumnIndex].DefaultCellStyle.Tag;
+ } else {
+ result.Tag = DataGridView.DefaultCellStyle.Tag;
+ }
+ }
+ if (style != null && style.WrapMode != DataGridViewTriState.NotSet) {
+ result.WrapMode = style.WrapMode;
+ } else if (OwningRow != null && OwningRow.DefaultCellStyle.WrapMode != DataGridViewTriState.NotSet) {
+ result.WrapMode = OwningRow.DefaultCellStyle.WrapMode;
+ } else if (DataGridView != null) {
+ if ((RowIndex % 2) == 1 && DataGridView.AlternatingRowsDefaultCellStyle.WrapMode != DataGridViewTriState.NotSet) {
+ result.WrapMode = DataGridView.AlternatingRowsDefaultCellStyle.WrapMode;
+ } else if (DataGridView.RowsDefaultCellStyle.WrapMode != DataGridViewTriState.NotSet) {
+ result.WrapMode = DataGridView.RowsDefaultCellStyle.WrapMode;
+ } else if (ColumnIndex >= 0 && DataGridView.Columns [ColumnIndex].DefaultCellStyle.WrapMode != DataGridViewTriState.NotSet) {
+ result.WrapMode = DataGridView.Columns [ColumnIndex].DefaultCellStyle.WrapMode;
+ } else {
+ result.WrapMode = DataGridView.DefaultCellStyle.WrapMode;
+ }
+ }
+ return result;
}
[EditorBrowsable (EditorBrowsableState.Advanced)]
[EditorBrowsable (EditorBrowsableState.Advanced)]
public virtual void PositionEditingControl (bool setLocation, bool setSize, Rectangle cellBounds, Rectangle cellClip, DataGridViewCellStyle cellStyle, bool singleVerticalBorderAdded, bool singleHorizontalBorderAdded, bool isFirstDisplayedColumn, bool isFirstDisplayedRow) {
- throw new NotImplementedException();
+ //throw new NotImplementedException();
+ if (setLocation)
+ DataGridView.EditingControl.Location = cellBounds.Location;
+
+ if (setSize)
+ DataGridView.EditingControl.Size = cellBounds.Size;
}
[EditorBrowsable (EditorBrowsableState.Advanced)]
}
protected virtual Rectangle GetContentBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
- throw new NotImplementedException();
+ return Rectangle.Empty;
}
protected virtual Rectangle GetErrorIconBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
}
protected virtual Size GetSize (int rowIndex) {
+ DataGridViewCellStyle style = InheritedStyle;
throw new NotImplementedException();
}
protected virtual object GetValue (int rowIndex) {
- throw new NotImplementedException();
+
+ if (DataGridView != null && (RowIndex < 0 || RowIndex >= DataGridView.Rows.Count))
+ throw new ArgumentOutOfRangeException ("rowIndex", "Specified argument was out of the range of valid values.");
+
+ return valuex;
}
protected virtual bool KeyDownUnsharesRow (KeyEventArgs e, int rowIndex) {
protected virtual void OnClick (DataGridViewCellEventArgs e) {
}
+ internal void OnClickInternal (DataGridViewCellEventArgs e) {
+ OnClick (e);
+ }
+
protected virtual void OnContentClick (DataGridViewCellEventArgs e) {
}
+
+ internal void OnContentClickInternal (DataGridViewCellEventArgs e) {
+ OnContentClick (e);
+ }
protected virtual void OnContentDoubleClick (DataGridViewCellEventArgs e) {
}
+
+ internal void OnContentDoubleClickInternal (DataGridViewCellEventArgs e) {
+ OnContentDoubleClick (e);
+ }
protected override void OnDataGridViewChanged () {
}
+
+ internal void OnDataGridViewChangedInternal () {
+ OnDataGridViewChanged ();
+ }
protected virtual void OnDoubleClick (DataGridViewCellEventArgs e) {
}
+ internal void OnDoubleClickInternal (DataGridViewCellEventArgs e) {
+ OnDoubleClick (e);
+ }
+
protected virtual void OnEnter (int rowIndex, bool throughMouseClick) {
}
+ internal void OnEnterInternal (int rowIndex, bool throughMouseClick) {
+ OnEnter (rowIndex, throughMouseClick);
+ }
+
protected virtual void OnKeyDown (KeyEventArgs e, int rowIndex) {
}
+ internal void OnKeyDownInternal (KeyEventArgs e, int rowIndex) {
+ OnKeyDown (e, rowIndex);
+ }
+
protected virtual void OnKeyPress (KeyPressEventArgs e, int rowIndex) {
}
+ internal void OnKeyPressInternal (KeyPressEventArgs e, int rowIndex) {
+ OnKeyPress (e, rowIndex);
+ }
+
protected virtual void OnKeyUp (KeyEventArgs e, int rowIndex) {
}
+
+ internal void OnKeyUpInternal (KeyEventArgs e, int rowIndex) {
+ OnKeyUp (e, rowIndex);
+ }
protected virtual void OnLeave (int rowIndex, bool throughMouseClick) {
}
+
+ internal void OnLeaveInternal (int rowIndex, bool throughMouseClick) {
+ OnLeave (rowIndex, throughMouseClick);
+ }
protected virtual void OnMouseClick (DataGridViewCellMouseEventArgs e) {
}
+ internal void OnMouseClickInternal (DataGridViewCellMouseEventArgs e) {
+ OnMouseClick (e);
+ }
+
protected virtual void OnMouseDoubleClick (DataGridViewCellMouseEventArgs e) {
}
+
+ internal void OnMouseDoubleClickInternal (DataGridViewCellMouseEventArgs e) {
+ OnMouseDoubleClick (e);
+ }
protected virtual void OnMouseDown (DataGridViewCellMouseEventArgs e) {
}
+ internal void OnMouseDownInternal (DataGridViewCellMouseEventArgs e) {
+ OnMouseDown (e);
+ }
+
protected virtual void OnMouseEnter (int rowIndex) {
}
+
+ internal void OnMouseEnterInternal (int rowIndex) {
+ OnMouseEnter (rowIndex) ;
+ }
protected virtual void OnMouseLeave (int rowIndex) {
}
+ internal void OnMouseLeaveInternal (int e) {
+ OnMouseLeave (e);
+ }
+
protected virtual void OnMouseMove (DataGridViewCellMouseEventArgs e) {
}
+
+ internal void OnMouseMoveInternal (DataGridViewCellMouseEventArgs e) {
+ OnMouseMove (e);
+ }
protected virtual void OnMouseUp (DataGridViewCellMouseEventArgs e) {
}
+ internal void OnMouseUpInternal (DataGridViewCellMouseEventArgs e) {
+ OnMouseUp (e);
+ }
+
protected virtual void Paint (Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) {
throw new NotImplementedException();
}
}
protected virtual bool SetValue (int rowIndex, object value) {
- throw new NotImplementedException();
+ if (valuex != value) {
+ valuex = value;
+ RaiseCellValueChanged (new DataGridViewCellEventArgs (ColumnIndex, RowIndex));
+ return true;
+ }
+ return false;
}
private void OnStyleChanged (object sender, EventArgs args) {
internal void SetOwningRow (DataGridViewRow row) {
owningRow = row;
}
+
+ internal void SetOwningColumn (DataGridViewColumn col) {
+ owningColumn = col;
+ }
internal void SetColumnIndex (int index) {
columnIndex = index;