Skip to content

Commit 51fbaeb

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

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27460,7 +27460,8 @@ 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] &&
2746527466
!_dataGridViewOper[OperationInDispose] &&
2746627467
!_dataGridViewOper[OperationInReleasingDataSource])

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

Lines changed: 1 addition & 11 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,16 +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-
}
2047+
CurrentCell = null;
20582048

20592049
if (DataConnection is null)
20602050
{

0 commit comments

Comments
 (0)