Skip to content

Commit 209b149

Browse files
committed
Moving tag OperationInReleasingDataSource to function "OnDataSourceDisposed" (#13362)
* Removing tag OperationInReleasingDataSource * Add judgment IsHandleCreated to before defining currentCell in function SetCurrentCellAddressCore
1 parent b33f1ba commit 209b149

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.Methods.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27460,10 +27460,10 @@ protected virtual bool SetCurrentCellAddressCore(int columnIndex,
2746027460
{
2746127461
int oldCurrentCellX = _ptCurrentCell.X;
2746227462
int oldCurrentCellY = _ptCurrentCell.Y;
27463-
if (oldCurrentCellX >= 0 &&
27463+
if (IsHandleCreated &&
27464+
oldCurrentCellX >= 0 &&
2746427465
!_dataGridViewState1[State1_TemporarilyResetCurrentCell] &&
27465-
!_dataGridViewOper[OperationInDispose] &&
27466-
!_dataGridViewOper[OperationInReleasingDataSource])
27466+
!_dataGridViewOper[OperationInDispose])
2746727467
{
2746827468
DataGridViewCell currentCell = CurrentCellInternal;
2746927469
if (!EndEdit(DataGridViewDataErrorContexts.Parsing | DataGridViewDataErrorContexts.Commit | DataGridViewDataErrorContexts.CurrentCellChange,

src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ public partial class DataGridView : Control, ISupportInitialize
224224
private const int OperationInEndEdit = 0x00400000;
225225
private const int OperationResizingOperationAboutToStart = 0x00800000;
226226
private const int OperationTrackKeyboardColResize = 0x01000000;
227-
private const int OperationInReleasingDataSource = 0x02000000;
228227
private const int OperationMouseOperationMask = OperationTrackColResize | OperationTrackRowResize |
229228
OperationTrackColRelocation | OperationTrackColHeadersResize | OperationTrackRowHeadersResize;
230229
private const int OperationKeyboardOperationMask = OperationTrackKeyboardColResize;
@@ -2045,17 +2044,7 @@ public object DataSource
20452044
newDataSource.Disposed += OnDataSourceDisposed;
20462045
}
20472046

2048-
_dataGridViewOper[OperationInReleasingDataSource] = true;
2049-
2050-
try
2051-
{
2052-
CurrentCell = null;
2053-
}
2054-
finally
2055-
{
2056-
_dataGridViewOper[OperationInReleasingDataSource] = false;
2057-
}
2058-
2047+
CurrentCell = null;
20592048
if (DataConnection is null)
20602049
{
20612050
DataConnection = new DataGridViewDataConnection(this);

0 commit comments

Comments
 (0)