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
365
UltraWinTree Error UltraTreeNode.CommitCellValues
posted

Hi,


We were on a really old version of Infragistics (11.2) and we recently upgraded to 16.1.

In the latest version, we found that we are getting an exception with the following code:

private void ut_Click(object sender, EventArgs e)
{
UltraTree utControl = (UltraTree)sender;
if (utControl.ActiveCell == null) return;

switch (utControl.ActiveCell.Column.Key)
{
case "Checked":
utControl.ActiveCell.AllowEdit = AllowCellEdit.Full;
utControl.ActiveCell.BeginEdit();
if ((CheckState)utControl.ActiveCell.Value == CheckState.Unchecked || (CheckState)utControl.ActiveCell.Value == CheckState.Indeterminate)
utControl.ActiveCell.Value = (int)CheckState.Checked;
else if ((CheckState)utControl.ActiveCell.Value == CheckState.Checked)
utControl.ActiveCell.Value = (int)CheckState.Unchecked;

utControl.ActiveCell.EndEdit(false);
utControl.ActiveNode.Update();

Here's the stack trace:

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at Infragistics.Win.UltraWinTree.UltraTreeNode.CommitCellValues()
at Infragistics.Win.UltraWinTree.UltraTreeNode.Update()
at OptiGlass.ctlOptimizer.ut_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at Infragistics.Win.UltraControlBase.OnClick(EventArgs e)
at System.Windows.Forms.Control.WmMouseUp(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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

I did a 

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at Infragistics.Win.UltraWinTree.UltraTreeNode.CommitCellValues()
at Infragistics.Win.UltraWinTree.UltraTreeNode.Update()
at OptiGlass.ctlOptimizer.ut_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at Infragistics.Win.UltraControlBase.OnClick(EventArgs e)
at System.Windows.Forms.Control.WmMouseUp(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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Not sure if we're doing something that was OK in 11.2 but is no longer OK in 16.1 or if this is a bug, but I wasn't able to find any information on this.

Thanks in advance!

Steve

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    Hi Steve,

    I don't see anything inherently wrong with this code. It might be a bug. But I would need a sample project demonstrating the exception in order to know for sure.

    I tried to create a sample, but I could not get it to work because there are too many unknowns here and a lot of this code just doesn't make a lot of sense to me.

    You seem to be jumping through some pretty big hoops here in order to manually handle clicking on a cell that contains both CheckState and/or integer values. If you just want a Checkbox or CheckState column then there are MUCH easier ways to do that built-in to the tree and there's no reason to write code in the Click event to handle that.

    What's the DataType of this column?

    Why are you manually handling the Click event to toggle the value?

    Also... the code you have will produce some very strange and unexpected results. You are not actually checking to see if the user is clicking on a cell. So if there is an ActiveCell in the tree and the user clicks on the tree's Background, a header, the scrollbar, or basically anything the doesn't change the ActiveCell to null, this code will end up toggling the ActiveCell even though the user clicked somewhere else.

    Anyway, presumably this code has been working for you for a long time, so it may not be worth messing with it. If you can provide a sample that reproduce the exception, we will, of course, be happy to look into it. But if all you need is a checkbox cell in the tree, it might be better to just simplify the code and use the built-in functionality instead of jumping through hoops like you are doing here. That might get you up and running faster and avoid the exception.

Children