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?
That is a bug. I took a look at the IsCellInEditMode implementation and it looks like a change was made in March 2006 that should have addressed something like this. It would seem there are two possibilites - you are using a version older than 2006 Vol2, or the change that was made does not address the scenario you describe here. If you are able to, post a brief sample that demonstrates this problem and I will check to see if it is still reproducible. Alternatively, you could get the latest hotfix and see if it resolnes this issue.
Is there something that I can do in my code to handle this? Like for e.g: Is there a way , I can prevent the control from going to the "IsCellInEditMode" since there is no cell here? The tree is empty. And this occurs only when I have a cell selected earlier. Otherwise there is no error which means this information of the selected cell is stored somewhere. Where is it stored? Can I remove that selected cell from there? Will it solve my problem?
You might try pulling the cell out of edit mode prior to resetting the data dource:
UltraTreeNodeCell activeCell = this.ultraTree1.ActiveCell;if ( activeCell != null ) activeCell.EndEdit( false );
I can't speculate any further about this without a simple sample that demonstrates the problem. As I stated previously, it could be a bug that has already been addressed, so you should probably get the latest hotfix.
I tried this code. But I'm still getting the same error. Any other solution?