Node objects not equal after assignment

Posted by: chasjimenez04 on 27 September 2017, 8:49 pm EST

    • Post Options:
    • Link

    Posted 27 September 2017, 8:49 pm EST

    Hi,

    I’m not sure if this an issue with VB.net or with the flexgrid control, but it does not happen when I use other objects.

    If I assign a flexgrid node object to another variable, I would expect them to point to the same node object. But this is not the case.

    Example:

    [vb]

    Dim tn As Node = grdTree.Nodes(4).Nodes(2) ’ where grdTree is a C1FlexGrid object I created Nodes in

    Dim TheyAreEqual As Boolean

    TheyAreEqual = (tn Is grdTree.Nodes(4).Nodes(2))

    Debug.Writeline(TheyAreEqual) ’ Outputs ‘False’

    [/vb]

    If I compare the results of grdTree.Nodes(3).GetHashCode and tn.GetHashCode, they are different.

    The same thing occurs if I compare in this way:

    [vb]

    Debug.Writeline(grdTree.Rows(10).Node Is grdTree.Nodes(4).Nodes(2)) ’ ← These are the same Node

    [/vb]

    This comparison also returns False.

    The kicker is that if I modify, say, the Data property of tn

    [vb]

    tn.Data = “New Data”

    [/vb]

    all three references will change to the new value! So they all seem to be the same object, yet I cannot compare them directly, and their hash values are different.

    As I mentioned above, I have tried this with other objects, and this does not happen. For now, I have resorted to comparing the Data property to check if the objects are the same.

    Any ideas?

    Debug.Writeline(

  • Posted 27 September 2017, 8:49 pm EST

    Hello,

    We could replicate the issue at our end as well. When any specific Node object is assigned to a new instance of Node and the two nodes are compared, it does not return ‘True’.

    We have escalated this to the development team and will let you know as soon as there is any revert from them.

    The tracking id for the issue is: 124263.

    Regards,

    Arpit Jain

  • Posted 8 March 2018, 2:25 am EST

    Hello,

    As per the team

    Node is a wrapper around Row object. FlexGrid doesn’t keep Node objects, it creates them every time when such object is required based on underlying Row. So comparison of nodes in attached sample returns false because the nodes are actually different objects. Customer can compare underlying rows instead:

    TheyAreEqual = (tn.Row Is grdTree.Nodes(4).Nodes(2).Row)
    
    

    It gives correct results

    Best Regards,

    Esha

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels