Standard-Toolkit icon indicating copy to clipboard operation
Standard-Toolkit copied to clipboard

[Bug]: `KryptonDataGridView` - NullReferenceException

Open Goddfrey opened this issue 2 years ago • 5 comments

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

Goddfrey avatar Jan 11 '24 06:01 Goddfrey

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

iwarp avatar Feb 04 '24 07:02 iwarp

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.

PWagner1 avatar Feb 04 '24 08:02 PWagner1

@Wagnerp here you go

https://github.com/iwarp/KryptonBugDemo

iwarp avatar Feb 04 '24 08:02 iwarp

Hi @iwarp & @Goddfrey

Please retry using nightly build >= .36

PWagner1 avatar Feb 05 '24 08:02 PWagner1

This is also related to the changes in #1368

Smurf-IV avatar Mar 03 '24 11:03 Smurf-IV

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?

giduac avatar Jun 18 '24 16:06 giduac

Hi @Wagnerp,

Please close as this seems to be solved in TK 80.24.3.64 and @Goddfrey does not respond to queries. TY.

giduac avatar Jun 25 '24 06:06 giduac