# Q1 2011 breaking changes

Treeview Top achievements Rank 1
Zensell asked on 17 Mar 2011, 04:44 PM
Hi, how should I fix these breaking changes?

- CompareNodesTagCommand has been removed.
- RadTreeNode.DataBoundItem is read-only. Is there a way to change it manually in unbound mode?
- TreeNodeUI has been removed.

Thanks.

## 3 Answers, 1 is accepted

0
Accepted Julian Benkov
Telerik team answered on 22 Mar 2011, 10:53 AM
Hello Zensell,

1) You can use new Find method of RadTreeView control for this behavior. Here is a small example:

`private` `object` `tagKey;`
`private` `bool` `FindByTag(RadTreeNode node)`
`{`
`    ``if` `(node.Tag != ``null``)`
`    ``{`
`        ``IComparable comparer = node.Tag ``as` `IComparable;`
`        ``if` `((comparer != ``null` `&& comparer.CompareTo(tagKey) == 0) ||`
`            ``node.Tag.Equals(key))`
`        ``{`
`            ``return` `true``;`
`        ``}`
`    ``}`

`    ``return` `false``;`
`}`

`private` `void` `radButton1_Click(``object` `sender, EventArgs e)`
`{`
`    ``RadTreeNode nodeByTag = ``this``.radTreeView1.Find(``this``.FindByTag);`
`}`

If you want to use the old Command aproach here is implementation of removed CompareNodesTagCommand command:
`public` `class` `CompareNodesTagCommand : CommandBase`
`{`
`    ``public` `override` `object` `Execute(``params` `object``[] settings)`
`    ``{`
`        ``if` `(settings.Length > 1 &&`
`            ``this``.CanExecute(settings))`
`        ``{`
`            ``RadTreeNode node = settings ``as` `RadTreeNode;`
`            ``object` `key = (settings ``as` `IList);`

`            ``if` `(node != ``null` `&& node.Tag != ``null``)`
`            ``{`
`                ``IComparable comparer = node.Tag ``as` `IComparable;`
`                ``if` `((comparer != ``null` `&& comparer.CompareTo(key) == 0) ||`
`                    ``node.Tag.Equals(key))`
`                ``{`
`                    ``return` `node;`
`                ``}`
`            ``}`
`        ``}`
`        ``return` `null``;`
`    ``}`

`    ``public` `override` `bool` `CanExecute(``object` `parameter)`
`    ``{`
`        ``if` `(``typeof``(RadTreeNode).IsAssignableFrom(parameter.GetType()))`
`        ``{`
`            ``return` `true``;`
`        ``}`
`        ``return` `base``.CanExecute(parameter);`
`    ``}`
`}`

2) The new Find command can be used implementing a different search callback function:
`private` `void` `radButton1_Click(``object` `sender, EventArgs e)`
`{`
`    ``RadTreeNode nodeByName = ``this``.radTreeView1.Find(``this``.FindByKey);`
`    ``RadTreeNode nodeByText = ``this``.radTreeView1.Find(``this``.FindByText);`
`}`

`private` `string` `key;`
`private` `bool` `FindByKey(RadTreeNode node)`
`{`
`    ``if` `((``this``.key == ``null``) || (node.Name == ``null``))`
`    ``{`
`        ``return` `false``;`
`    ``}`

`    ``if` `(``this``.key.Length != node.Name.Length)`
`    ``{`
`        ``return` `false``;`
`    ``}`

`    ``return` `(``string``.Compare(``this``.key, node.Name, ``true``, CultureInfo.InvariantCulture) == 0);`
`}`

`private` `string` `text;`
`private` `bool` `FindByText(RadTreeNode node)`
`{`
`    ``if` `((``this``.text == ``null``) || (node.Text == ``null``))`
`    ``{`
`        ``return` `false``;`
`    ``}`

`    ``if` `(``this``.text.Length != node.Text.Length)`
`    ``{`
`        ``return` `false``;`
`    ``}`

`    ``return` `(``string``.Compare(``this``.text, node.Text, ``true``, CultureInfo.InvariantCulture) == 0);`
`}`

3) DataBoundItem is used only in bound mode and can not be changed at run time. You can use the Tag property to reference your custom business object related to RadTreeNode object.

4) TreeNodeUI element is changed with TreeNodeElement that supports full customization. More information you can refer in our online documentation or in our Examples application, section TreeView >> Customize.

All the best,
Julian Benkov
the Telerik team
0 MP
Top achievements Rank 1
answered on 25 May 2011, 08:02 PM

Dear Telerik,

We were using the TreeNodeUI.AssociatedNode property and now are not sure how to access this property with the new release. We had used the following code to find out which node was being double-clicked. Please advise.

`foreach` `(TreeNodeUI treeNodeUI ``in` `this``.radTreeView1.TreeViewElement.Items) `
`{ `
`    ``if` `(treeNodeUI.AssociatedTreeNode == radTreeView1.SelectedNode) `
`    ``{ `
`        ``uiNode = treeNodeUI; `
`        ``break``; `
`    ``} `
`} `
`if` `(uiNode != ``null``) `
`{ `
`    ``if` `(uiNode.BoundingRectangle.Contains(e.Location)) `
`    ````{            //do stuff         } } ```
0 Julian Benkov
Telerik team answered on 28 May 2011, 12:23 PM
Hello MP,

For this scenario you can use following code snippet:

`TreeNodeElement nodeElement = ``this``.radTreeView1.TreeViewElement.GetElement(``this``.radTreeView1.SelectedNode);`
`if` `(nodeElement != ``null` `&& nodeElement.BoundingRectangle.Contains(e.Location))`
`{`
`    ``//TO DO`
`}`

Do not hesitate to contact us if you have further questions or issues.

Best wishes,
Julian Benkov
the Telerik team
Tags
Treeview Zensell
Top achievements Rank 1 Rank 1
{"ft_lang_label":"__label__en","ft_lang_prob":0.61155444,"math_prob":0.42664975,"size":4783,"snap":"2022-05-2022-21","text_gpt3_token_len":1184,"char_repetition_ratio":0.13391922,"word_repetition_ratio":0.46348315,"special_character_ratio":0.23938951,"punctuation_ratio":0.18872549,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9581831,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-05-29T11:33:43Z\",\"WARC-Record-ID\":\"<urn:uuid:44f30e86-af92-4b41-af41-129d699a6f23>\",\"Content-Length\":\"145199\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b2d60dd8-aec9-4e87-8b61-6f5f4bcf2851>\",\"WARC-Concurrent-To\":\"<urn:uuid:c8ce9c36-3a3d-4b48-84fe-f76ef5a83e34>\",\"WARC-IP-Address\":\"50.56.19.112\",\"WARC-Target-URI\":\"https://www.telerik.com/forums/q1-2011-breaking-changes\",\"WARC-Payload-Digest\":\"sha1:HRBHEKTZ2BHL474YHSI5SG3XDFBR7FID\",\"WARC-Block-Digest\":\"sha1:GEELWWFXIYTQHURDADMIRFC2V7GWFVJU\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-21/CC-MAIN-2022-21_segments_1652662644142.66_warc_CC-MAIN-20220529103854-20220529133854-00383.warc.gz\"}"}