} else {
Controls.Remove (editingControl);
}
+ editingControl.Dispose();
}
int new_width = 0;
if (rowHeadersWidthSizeMode == DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders) {
- foreach (DataGridViewRow row in Rows)
- if (row.Displayed)
+ bool anyRowsDisplayed = false;
+ foreach(DataGridViewRow row in Rows)
+ if(row.Displayed) {
+ anyRowsDisplayed = true;
new_width = Math.Max (new_width, row.HeaderCell.PreferredSize.Width);
-
+ }
+
+ // if there are no rows which are displayed, we still have to set new_width
+ // to a value >= 4 as RowHeadersWidth will throw an exception otherwise
+ if(!anyRowsDisplayed) {
+ foreach (DataGridViewRow row in Rows)
+ new_width = Math.Max (new_width, row.HeaderCell.PreferredSize.Width);
+ }
+
if (RowHeadersWidth != new_width)
RowHeadersWidth = new_width;
InvalidateRow (i);
}
+ private void UpdateRowHeightInfo (DataGridViewRow row)
+ {
+ DataGridViewRowHeightInfoNeededEventArgs rowInfo =
+ new DataGridViewRowHeightInfoNeededEventArgs (row.Index, row.Height, row.MinimumHeight);
+ OnRowHeightInfoNeeded (rowInfo);
+
+ if (row.Height != rowInfo.Height || row.MinimumHeight != rowInfo.MinimumHeight) {
+ row.MinimumHeight = rowInfo.MinimumHeight;
+ row.Height = rowInfo.Height;
+ OnRowHeightInfoPushed (new DataGridViewRowHeightInfoPushedEventArgs (row.Index, rowInfo.Height,
+ rowInfo.MinimumHeight));
+ }
+ }
+
public void UpdateRowHeightInfo (int rowIndex, bool updateToEnd)
{
if (rowIndex < 0 && updateToEnd)
if (updateToEnd) {
for (int i = rowIndex; i < Rows.Count; i++) {
- DataGridViewRow row = Rows[i];
- if (!row.Visible)
- continue;
-
- DataGridViewRowHeightInfoNeededEventArgs rowInfo =
- new DataGridViewRowHeightInfoNeededEventArgs (row.Index, row.Height, row.MinimumHeight);
- OnRowHeightInfoNeeded (rowInfo);
-
- if (row.Height != rowInfo.Height || row.MinimumHeight != rowInfo.MinimumHeight) {
- row.Height = rowInfo.Height;
- row.MinimumHeight = rowInfo.MinimumHeight;
- OnRowHeightInfoPushed (new DataGridViewRowHeightInfoPushedEventArgs (row.Index, rowInfo.Height,
- rowInfo.MinimumHeight));
- }
+ DataGridViewRow row = Rows [i];
+ if (row.Visible)
+ UpdateRowHeightInfo (row);
}
} else {
- DataGridViewRow row = Rows[rowIndex];
- DataGridViewRowHeightInfoNeededEventArgs rowInfo =
- new DataGridViewRowHeightInfoNeededEventArgs (row.Index, row.Height, row.MinimumHeight);
- OnRowHeightInfoNeeded (rowInfo);
-
- if (row.Height != rowInfo.Height || row.MinimumHeight != rowInfo.MinimumHeight) {
- row.Height = rowInfo.Height;
- row.MinimumHeight = rowInfo.MinimumHeight;
- OnRowHeightInfoPushed (new DataGridViewRowHeightInfoPushedEventArgs (row.Index, rowInfo.Height,
- rowInfo.MinimumHeight));
- }
+ UpdateRowHeightInfo (Rows [rowIndex]);
}
}
}
protected override void Dispose (bool disposing) {
+ if (disposing) {
+ ClearSelection();
+ currentCell = null;
+ foreach (DataGridViewColumn column in Columns)
+ column.Dispose();
+ Columns.Clear();
+ foreach (DataGridViewRow row in Rows)
+ row.Dispose();
+ Rows.Clear();
+ }
+ editingControl = null;
+
+ base.Dispose(disposing);
}
protected override AccessibleObject GetAccessibilityObjectById (int objectId)
DataGridViewCell cell = CurrentCell;
if (cell != null) {
- if (cell.KeyEntersEditMode (new KeyEventArgs ((Keys)m.WParam.ToInt32 ())))
+ if (cell.KeyEntersEditMode (new KeyEventArgs (((Keys)m.WParam.ToInt32 ()) | XplatUI.State.ModifierKeys)))
BeginEdit (true);
if (EditingControl != null && ((Msg)m.Msg == Msg.WM_KEYDOWN || (Msg)m.Msg == Msg.WM_CHAR))
XplatUI.SendMessage (EditingControl.Handle, (Msg)m.Msg, m.WParam, m.LParam);
protected override bool ProcessKeyPreview (ref Message m)
{
if ((Msg)m.Msg == Msg.WM_KEYDOWN && (IsCurrentCellInEditMode || m.HWnd == horizontalScrollBar.Handle || m.HWnd == verticalScrollBar.Handle)) {
- KeyEventArgs e = new KeyEventArgs ((Keys)m.WParam.ToInt32 ());
+ KeyEventArgs e = new KeyEventArgs (((Keys)m.WParam.ToInt32 ()) | XplatUI.State.ModifierKeys);
IDataGridViewEditingControl ctrl = (IDataGridViewEditingControl)EditingControlInternal;
horizontalScrollBar.SafeValueSet (horizontalScrollBar.Value - delta_x);
OnHScrollBarScroll (this, new ScrollEventArgs (ScrollEventType.ThumbPosition, horizontalScrollBar.Value));
- } else if (disp_x > first_col_index + displayedColumnsCount - 1) {
+ } else if (disp_x > first_col_index + displayedColumnsCount - 1 && disp_x != 0) {
RefreshScrollBars ();
scrollbarsRefreshed = true;
verticalScrollBar.SafeValueSet (verticalScrollBar.Value - delta_y);
OnVScrollBarScroll (this, new ScrollEventArgs (ScrollEventType.ThumbPosition, verticalScrollBar.Value));
- } else if (disp_y > first_row_index + displayedRowsCount - 1) {
+ } else if (disp_y > first_row_index + displayedRowsCount - 1 && disp_y != 0) {
if (!scrollbarsRefreshed)
RefreshScrollBars ();