[Bug]: `KryptonDataGridView` - NullReferenceException
Describe the bug To Reproduce Exception occurs sometimes randomly, but there's one scenario where it happens 100 % of the time:
Windows Form with KryptonDataGridView is open. I choose "settings" from the menu strip. SettingsForm.ShowDialog() opens (that has no datagridview). I click OK, settings form closes, main form with KryptonDataGridView is an active window again. I do nothing at all. In about 4 - 6 seconds it crashes with this exception.
at Krypton.Toolkit.KryptonDataGridViewButtonCell.get_MouseInContentBoundsInternal()
at Krypton.Toolkit.KryptonDataGridViewButtonCell.Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, Int32 rowIndex, DataGridViewElementStates cellState, Object value, Object formattedValue, String errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
at System.Windows.Forms.DataGridViewCellPaintingEventArgs.Paint(Rectangle clipBounds, DataGridViewPaintParts paintParts)
at Krypton.Toolkit.KryptonDataGridView.OnCellPainting(DataGridViewCellPaintingEventArgs e)
at System.Windows.Forms.DataGridViewCell.PaintWork(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, Int32 rowIndex, DataGridViewElementStates cellState, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
at System.Windows.Forms.DataGridViewRow.PaintCells(Graphics graphics, Rectangle clipBounds, Rectangle rowBounds, Int32 rowIndex, DataGridViewElementStates rowState, Boolean isFirstDisplayedRow, Boolean isLastVisibleRow, DataGridViewPaintParts paintParts)
at System.Windows.Forms.DataGridViewRow.Paint(Graphics graphics, Rectangle clipBounds, Rectangle rowBounds, Int32 rowIndex, DataGridViewElementStates rowState, Boolean isFirstDisplayedRow, Boolean isLastVisibleRow)
at System.Windows.Forms.DataGridView.PaintRows(Graphics g, Rectangle boundingRect, Rectangle clipRect, Boolean singleHorizontalBorderAdded)
at System.Windows.Forms.DataGridView.PaintGrid(Graphics g, Rectangle gridBounds, Rectangle clipRect, Boolean singleVerticalBorderAdded, Boolean singleHorizontalBorderAdded)
at System.Windows.Forms.DataGridView.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at Krypton.Toolkit.KryptonDataGridView.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(HWND hWnd, MessageId msg, WPARAM wparam, LPARAM lparam)
Desktop (please complete the following information):
- OS: Windows 10 Pro
- Version: OS build 19045.3930, Windows Feature Experience Pack 1000.19053.1000.0
- Framework/.NET Version: 8.0
- Toolkit Version: 80.23.11.321
I've also experienced this same bug but have been able to reproduce it with a KryptonDataGridView with a single KryptonDataGridViewButtonColumn and mouse over the button.
This only fails on .NET 8.0 for me, moving my test project back to .NET 7.0 works as expected.
Something in the GetFeild has changes in .NET 7 and 8 https://github.com/Krypton-Suite/Standard-Toolkit/blob/4c38c8492a2290291047e2f668fa17efe8417931/Source/Krypton%20Components/Krypton.Toolkit/Controls%20Toolkit/KryptonDataGridViewButtonCell.cs#L371C89-L371C109
Hi @Goddfrey & @iwarp
Would you mind uploading a sample app, demonstrating the bug? I think that I've resolved the bug, but need to validate the fix.
@Wagnerp here you go
https://github.com/iwarp/KryptonBugDemo
Hi @iwarp & @Goddfrey
Please retry using nightly build >= .36
This is also related to the changes in #1368
Hi @Goddfrey,
Been looking into this. It clearly faults with: Toolkit 80.23.11.321
When using TK 80.24.3.64 I don't get the error, Tested this with Net 48 / 6 / 7 / 8
Would you be able to try this version and let us know the results?
Hi @Wagnerp,
Please close as this seems to be solved in TK 80.24.3.64 and @Goddfrey does not respond to queries. TY.