Nevron Forum

Tree List Exception!

https://www.nevron.com/Forum/Topic3041.aspx

By Fabian Baptista 1 - Thursday, February 4, 2010

I only have simple code using TreeList control in version 2008 Q2
I need help.

nTreeList1.Nodes.Clear();

NTreeListNode node1 = new NTreeListNode();
node1.ImageIndex = 1;

NTreeListNodeStringSubItem sub1 = new NTreeListNodeStringSubItem();
sub1.Text = "";
sub1.Column = nTreeList1.Columns[1];


node1.SubItems.Add(sub1);
nTreeList1.Nodes.Add(node1);



When the tree list is displayed, when I click the column (to sort) I'm facing this error.


Exception:
System.InvalidCastException: Unable to cast object of type 'Nevron.UI.WinForm.Controls.NTreeListNode' to type 'Nevron.UI.WinForm.Controls.NTreeListHeaderItem'.
at Nevron.UI.WinForm.Controls.NTreeList.MapRect(NRectangle rect, NLightUIItem item)
at Nevron.UI.WinForm.Controls.NTreeList.GetItemRect(NLightUIItem item)
at Nevron.UI.WinForm.Controls.NItemsControl.Refre****em(NLightUIItem item)
at Nevron.UI.WinForm.Controls.NTreeList.l1II11lIII(Boolean l1II1lIIl1)
at Nevron.UI.WinForm.Controls.NTreeList.OnHeaderEndResize(NLightUIItemNotifyData data)
at Nevron.UI.WinForm.Controls.NTreeList.ProcessHeaderItemNotify(NLightUIItemNotifyData data)
at Nevron.UI.WinForm.Controls.NTreeList.l1IIlI1l1I(NLightUIItemNotifyData data)
at Nevron.UI.WinForm.Controls.NTreeList.l1I1Il11II(NLightUIItemNotifyData data)
at Nevron.UI.WinForm.Controls.NTreeListHeaderItem.ProcessMouseUp(MouseEventArgs e)
at Nevron.UI.WinForm.Controls.NLightUIItem.OnMouseUp(MouseEventArgs e)
at Nevron.UI.WinForm.Controls.NItemsControl.OnMouseUp(MouseEventArgs e)
at Nevron.UI.WinForm.Controls.NTreeViewEx.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at Nevron.UI.WinForm.Controls.NItemsControl.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.RunDialog(Form form)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
By Fabian Baptista 1 - Thursday, February 4, 2010

Hi there
Finnaly I found some problems when you set a NTreeListNodeStringSubItem Text property on null;

The tree view control shows data rows as "", but when the user click on column in order to sort elements, the Tree List throws exceptions.

So, I replace all null values to "".
Thanks for hear