@@ -14910,22 +14910,7 @@ protected virtual void OnDataSourceChanged(EventArgs e)
1491014910    /// <summary>
1491114911    ///  Refresh items when the DataSource is disposed.
1491214912    /// </summary>
14913-     private void OnDataSourceDisposed(object? sender, EventArgs e)
14914-     {
14915-         try
14916-         {
14917-             // 1. Modify the state of the current operation to avoid unnecessary operations
14918-             // when setting DataSource and CurrentCell.
14919-             // 2. Setting CurrentCell to null then release DataSource.
14920-             _dataGridViewOper[OperationInReleasingDataSource] = true;
14921-             CurrentCell = null;
14922-             DataSource = null;
14923-         }
14924-         finally
14925-         {
14926-             _dataGridViewOper[OperationInReleasingDataSource] = false;
14927-         }
14928-     }
14913+     private void OnDataSourceDisposed(object? sender, EventArgs e) => DataSource = null;
1492914914
1493014915    protected virtual void OnDefaultCellStyleChanged(EventArgs e)
1493114916    {
@@ -27032,11 +27017,10 @@ protected virtual bool SetCurrentCellAddressCore(int columnIndex,
2703227017                int oldCurrentCellY = _ptCurrentCell.Y;
2703327018                if (oldCurrentCellX >= 0
2703427019                    && !_dataGridViewState1[State1_TemporarilyResetCurrentCell]
27035-                     && !_dataGridViewOper[OperationInDispose]
27036-                     && !_dataGridViewOper[OperationInReleasingDataSource])
27020+                     && !_dataGridViewOper[OperationInDispose])
2703727021                {
2703827022                    DataGridViewCell currentCell = CurrentCellInternal;
27039-                     if (!EndEdit(
27023+                     if (IsHandleCreated &&  !EndEdit(
2704027024                        DataGridViewDataErrorContexts.Parsing | DataGridViewDataErrorContexts.Commit | DataGridViewDataErrorContexts.CurrentCellChange,
2704127025                        validateCurrentCell ? DataGridViewValidateCellInternal.Always : DataGridViewValidateCellInternal.Never,
2704227026                        fireCellLeave: validateCurrentCell,
0 commit comments