We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

FInd TreeViewItemAdv by header/tag/name

Thread ID:

Created:

Updated:

Platform:

Replies:

99128 May 1,2011 07:47 AM UTC May 18,2011 07:21 AM UTC WPF 1
loading
Tags: Tools
Administrator [Syncfusion]
Asked On May 1, 2011 07:47 AM UTC


I need to add new child Items to my TreeViewAdv according to the existing items name/header/tag.

for example I've added this item:

TreeViewItemAdv tvi = new TreeViewItemAdv()
{
Header ="Item1",
Tag = "Item1_Tag" + r[2].ToString(),
IsExpanded = true

};

myTree.Items.Add(tvi);

how do I than search for this Item in a loop, and match it's name/header/tag to an exisiting string?


I want to match a string to an existing item's header/tag/name and if a match was found add a child item to this item

thanks








Karthika T B [Syncfusion]
Replied On May 18, 2011 07:21 AM UTC

Hi Assaf,

Thanks for choosing Syncfusion products.

We have created a simple sample based on your requirement and the sample can be downloaded from the following location:

Sample: http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=treeview5-7830128.zip

We have illustrated about the SearchItemByPath Method below:

New method ' SearchItemByPath ' has been provided to search the items by providing treeviewitem header path and final return value of this method is the treeviewitem which has been searched.

Overloaded Methods of SearchItemByPath :

1) SearchItemByPath(string path, char pathseperator)

- where path can be defined as 'Well1:Run1' where Well1 is first level TreeViewItem Header and Run1 is the next level TreeViewItem Header which is the child of Well1 and charseperator is ':'.

2) SearchItemByPath(string path, char pathseperator, bool IsSelected)

- Similar to first method which returns the treeviewitem of Run1 and the third bool parameter decides the treeviewitem to be selected or not.

3) SearchItemByPath(string path, char pathseperator, string propertyname)

- This method is also similar to first method but this method used to search when treeviewitem are added as collection objects and binded to Itemsource. Here instead of Header you can specify the value of object as path. For example Well is the class with Name and Description and these object has been binded as treeviewitem then you can mention the path hierarchy using name or description value if name is used for Path then that corresponding third parameter should be "Name".

4) SearchItemByPath(string path, char pathseperator, string propertyname, bool IsSelected)

- Similar to third method which returns the treeviewitem and the fourth bool parameter decides the treeviewitem to be selected or not.


Please let us know if you have any questions about this.

Regards,
Karthika




treeview5_d6fe986d.zip

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;