No exception if DataGridView is null
Previously, a NullReferenceException was thrown in DataGridViewHeaderCell.MouseDownUnsharesRow(DataGridViewCellMouseEventArgs), DataGridViewHeaderCell.MouseEnterUnsharesRow(Int32), DataGridViewHeaderCell.MouseLeaveUnsharesRow(Int32), and DataGridViewHeaderCell.MouseUpUnsharesRow(DataGridViewCellMouseEventArgs) if the DataGridView property was null. That behavior was unexpected and incorrect. These methods have been updated to simply return false
if DataGridView
is null
.
Version introduced
.NET 9 Preview 1
Previous behavior
Previously, the affected methods threw a NullReferenceException when DataGridViewHeaderCell.DataGridView
was null
.
New behavior
Starting in .NET 9, the affected methods return false
if the DataGridViewHeaderCell.DataGridView
property is null
Change category
This change is a behavioral change.
Reason for change
The previous behavior was incorrect.
Recommended action
If you were relying on the code to throw a NullReferenceException in this scenario, change your code to check the return value instead.
Affected APIs
- System.Windows.Forms.DataGridViewHeaderCell.MouseDownUnsharesRow(DataGridViewCellMouseEventArgs)
- System.Windows.Forms.DataGridViewHeaderCell.MouseEnterUnsharesRow(Int32)
- System.Windows.Forms.DataGridViewHeaderCell.MouseLeaveUnsharesRow(Int32)
- System.Windows.Forms.DataGridViewHeaderCell.MouseUpUnsharesRow(DataGridViewCellMouseEventArgs)
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for