protected internal virtual void ColumnStartedEditing(Rectangle bounds)
 {
     DataGridRow[] dataGridRows = this.DataGridRows;
     if ((bounds.IsEmpty && (this.editColumn is DataGridTextBoxColumn)) && ((this.currentRow != -1) && (this.currentCol != -1)))
     {
         DataGridTextBoxColumn editColumn = this.editColumn as DataGridTextBoxColumn;
         Rectangle cellBounds = this.GetCellBounds(this.currentRow, this.currentCol);
         this.gridState[0x10000] = true;
         try
         {
             editColumn.TextBox.Bounds = cellBounds;
         }
         finally
         {
             this.gridState[0x10000] = false;
         }
     }
     if (this.gridState[0x100000])
     {
         int dataGridRowsLength = this.DataGridRowsLength;
         DataGridRow[] newRows = new DataGridRow[dataGridRowsLength + 1];
         for (int i = 0; i < dataGridRowsLength; i++)
         {
             newRows[i] = dataGridRows[i];
         }
         newRows[dataGridRowsLength] = new DataGridAddNewRow(this, this.myGridTable, dataGridRowsLength);
         this.SetDataGridRows(newRows, dataGridRowsLength + 1);
         this.Edit();
         this.gridState[0x100000] = false;
         this.gridState[0x8000] = true;
         this.gridState[0x4000] = false;
     }
     else
     {
         this.gridState[0x8000] = true;
         this.gridState[0x4000] = false;
         this.InvalidateRowHeader(this.currentRow);
         dataGridRows[this.currentRow].LoseChildFocus(this.layout.RowHeaders, this.isRightToLeft());
     }
 }
 private void DeleteDataGridRows(int deletedRows)
 {
     if (deletedRows != 0)
     {
         int dataGridRowsLength = this.DataGridRowsLength;
         int newRowsLength = (dataGridRowsLength - deletedRows) + (this.gridState[0x100000] ? 1 : 0);
         DataGridRow[] newRows = new DataGridRow[newRowsLength];
         DataGridRow[] dataGridRows = this.DataGridRows;
         int num3 = 0;
         for (int i = 0; i < dataGridRowsLength; i++)
         {
             if (dataGridRows[i].Selected)
             {
                 num3++;
             }
             else
             {
                 newRows[i - num3] = dataGridRows[i];
                 newRows[i - num3].number = i - num3;
             }
         }
         if (this.gridState[0x100000])
         {
             newRows[dataGridRowsLength - num3] = new DataGridAddNewRow(this, this.myGridTable, dataGridRowsLength - num3);
             this.gridState[0x100000] = false;
         }
         this.SetDataGridRows(newRows, newRowsLength);
     }
 }
 public void NavigateBack()
 {
     if (this.CommitEdit() && !this.parentRows.IsEmpty())
     {
         if (this.gridState[0x100000])
         {
             this.gridState[0x100000] = false;
             try
             {
                 this.listManager.CancelCurrentEdit();
             }
             catch
             {
             }
         }
         else
         {
             this.UpdateListManager();
         }
         DataGridState state = this.parentRows.PopTop();
         this.ResetMouseState();
         state.PullState(this, false);
         if (this.parentRows.GetTopParent() == null)
         {
             this.originalState = null;
         }
         DataGridRow[] dataGridRows = this.DataGridRows;
         if ((this.ReadOnly || !this.policy.AllowAdd) == (dataGridRows[this.DataGridRowsLength - 1] is DataGridAddNewRow))
         {
             int num = (this.ReadOnly || !this.policy.AllowAdd) ? (this.DataGridRowsLength - 1) : (this.DataGridRowsLength + 1);
             DataGridRow[] newRows = new DataGridRow[num];
             for (int i = 0; i < Math.Min(num, this.DataGridRowsLength); i++)
             {
                 newRows[i] = this.DataGridRows[i];
             }
             if (!this.ReadOnly && this.policy.AllowAdd)
             {
                 newRows[num - 1] = new DataGridAddNewRow(this, this.myGridTable, num - 1);
             }
             this.SetDataGridRows(newRows, num);
         }
         dataGridRows = this.DataGridRows;
         if (((dataGridRows != null) && (dataGridRows.Length != 0)) && (dataGridRows[0].DataGridTableStyle != this.myGridTable))
         {
             for (int j = 0; j < dataGridRows.Length; j++)
             {
                 dataGridRows[j].DataGridTableStyle = this.myGridTable;
             }
         }
         if ((this.myGridTable.GridColumnStyles.Count > 0) && (this.myGridTable.GridColumnStyles[0].Width == -1))
         {
             this.InitializeColumnWidths();
         }
         this.currentRow = (this.ListManager.Position == -1) ? 0 : this.ListManager.Position;
         if (!this.AllowNavigation)
         {
             this.RecreateDataGridRows();
         }
         this.caption.BackButtonActive = (this.parentRows.GetTopParent() != null) && this.AllowNavigation;
         this.caption.BackButtonVisible = this.caption.BackButtonActive;
         this.caption.DownButtonActive = this.parentRows.GetTopParent() != null;
         base.PerformLayout();
         base.Invalidate();
         if (this.vertScrollBar.Visible)
         {
             this.vertScrollBar.Value = this.firstVisibleRow;
         }
         if (this.horizScrollBar.Visible)
         {
             this.horizScrollBar.Value = this.HorizontalOffset + this.negOffset;
         }
         this.Edit();
         this.OnNavigate(new NavigateEventArgs(false));
     }
 }
 private void CreateDataGridRows()
 {
     CurrencyManager listManager = this.ListManager;
     DataGridTableStyle myGridTable = this.myGridTable;
     this.InitializeColumnWidths();
     if (listManager == null)
     {
         this.SetDataGridRows(new DataGridRow[0], 0);
     }
     else
     {
         int count = listManager.Count;
         if (this.policy.AllowAdd)
         {
             count++;
         }
         DataGridRow[] newRows = new DataGridRow[count];
         for (int i = 0; i < listManager.Count; i++)
         {
             newRows[i] = new DataGridRelationshipRow(this, myGridTable, i);
         }
         if (this.policy.AllowAdd)
         {
             this.addNewRow = new DataGridAddNewRow(this, myGridTable, count - 1);
             newRows[count - 1] = this.addNewRow;
         }
         else
         {
             this.addNewRow = null;
         }
         this.SetDataGridRows(newRows, count);
     }
 }