devexpress通过标签页面打开用户控件,数据窗口嵌入用户控件中。当点击数据窗口含下拉数据窗口字段时出现如下错误:
未处理 System.NullReferenceException
Message="未将对象引用设置到对象的实例。"
Source="DataWindowInterop"
StackTrace:
在 DataWindowInterop.DW_Events.CatchNotify(Int32 given_HWND, UInt32 Message, UInt32 wParam, Int32 lParam, Void* VM_Object)
在 System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
在 System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
在 System.Windows.Forms.Control.DefWndProc(Message& m)
在 System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 Sybase.DataWindow.DataWindowControl.WndProc(Message& msg)
分析原因,可能是子数据窗口找不到窗口句柄导致出错。
解决方法:继承Sybase.DataWindow.DataWindowControl,覆盖重写WndProc并捕捉异常,让错误不再传递到数据窗口控件外层。
原文:http://www.cnblogs.com/janehlp/p/4927715.html