DataGridView: sporadic NullReferenceException when trying to display the tooltip
See original GitHub issue.NET version
.NET version: 6.0.300 Windows version: Windows 7 using classic theme
Did it work in .NET Framework?
I’m not 100% sure whether it works in .NET Framework but I did not face this issue earlier.
Issue description
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Windows.Forms.Control.GetSafeHandle(IWin32Window window)
at Interop.ComCtl32.ToolInfoWrapper`1..ctor(T handle, TTF flags, String text)
at System.Windows.Forms.ToolTip.TryGetBubbleSize(IKeyboardToolTip tool, Rectangle toolRectangle, Size& bubbleSize)
at System.Windows.Forms.ToolTip.ShowKeyboardToolTip(String text, IKeyboardToolTip tool, Int32 duration)
at System.Windows.Forms.KeyboardToolTipStateMachine.ShowToolTip(IKeyboardToolTip tool, ToolTip toolTip)
at System.Windows.Forms.KeyboardToolTipStateMachine.Transition(IKeyboardToolTip tool, ToolTip tooltip, SmEvent event)
at System.Windows.Forms.KeyboardToolTipStateMachine.Transit(SmEvent event, IKeyboardToolTip source)
at System.Windows.Forms.KeyboardToolTipStateMachine.<SetupInitShowTimer>b__25_0(Timer sender)
at System.Windows.Forms.KeyboardToolTipStateMachine.<>c__DisplayClass27_0.<GetOneRunTickHandler>g__wrapper|0(Object sender, EventArgs eventArgs)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)
Steps to reproduce
It occurs randomly (up to a couple of times per day) at one of my customer’s computer who uses Windows 7 with visual styles disabled (classic theme).
The DataGridView
is rapidly updated via its DataSource
(in every 100ms). It does not have any tooltip configured so it must be the default tooltip when the cell is too small to be able to display the entire text.
I apologize for not being able to provide a more specific reproduction but please refer to the provided strack trace, which clearly indicates that some handle must be invalid in the ToolInfoWrapper<T>
constructor when the size of the tooltip is attempted to be determined.
I could never reproduce it locally maybe because I use Windows 10.
Issue Analytics
- State:
- Created a year ago
- Comments:13 (10 by maintainers)
Top GitHub Comments
@koszeggy I’m glad you were able to find a solution. @Amy-Li03 thanks for all the repro tries 😄 . I am going to close the issue as there is no action to take at this point on our side.
@Olina-Zhang can your team try to reproduce this in .NET 8 with using keyboard navigation in a full DGV? The specific thing I’m interested in is the keyboard scrolling through the DataGridView.