Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
235
Object Reference Error
posted

I am using an ultratree with the ViewStyle set to Grid. There is a dropdown on top of the page. Whenever the value in the dropdown is changed, the tree reloads with a new datasource. Now if I click to select one of the cells displayed in the tree and then change the value in the dropdown such that the new datasource does not return any value, then no data is displayed in the tree. This is as expected. But when I click on this empty space, I get an object reference error. However if I don't select any cell in the previous view and then click on this empty space, then there is no error.  The call stack is as follows:

  "System.NullReferenceException: Object reference not set to an instance of an object.
   at Infragistics.Win.UltraWinTree.UltraTree.get_IsCellInEditMode()
   at Infragistics.Win.UltraWinTree.UltraTree.OnMouseDown(MouseEventArgs e)
   at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)"

 It seems from the call stack that there is a check to see if the cell is in edit mode. Now since in this case, there is no cell, its throwing that error. But how do I handle this?