Answer the question
In order to leave comments, you need to log in
Why does it throw a NullReferenceException when accessing base?
Sometimes a NullReferenceException message is thrown in a class inherited from TreeView when accessing base.
How is this even possible and how to fix it?
Thank you.
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_ERASEBKGND)
{
m.Result = IntPtr.Zero;
}
else if (this.ExpandSingleClick && m.Msg == WM_LBUTTONDBLCLK)
{
m.Result = IntPtr.Zero;
}
else
{
base.WndProc(ref m); // Ошибка вылазит на этой строке
}
}
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Windows.Forms.TreeView.CustomDraw(Message& m)
at System.Windows.Forms.TreeView.WmNotify(Message& m)
at System.Windows.Forms.TreeView.WndProc(Message& m)
at Kstudio.Forms.ShellControls.TreeViewBase.WndProc(Message& m) in TreeViewBase.cs:line 215
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question