I have a TreeView which will be populated with some Nodes. The problem is, this nodes can have different Tag and Name property but some of them can have the same Text property.
I want to have only one node from each of above nodes, so the TreeView will have unique nodes by Text.
I am trying to make a list of all nodes then filter them, then add the new List to the TreeView. Here is my approach, and I commented the line which does not compile.
//Remove Duplicated Nodes
List<TreeNode> oldPinGrpNodes = new List<TreeNode>();
List<TreeNode> newPinGrpNodes = new List<TreeNode>();
TreeNode tempNode;
foreach (TreeNode node in tvPinGroups.Nodes)
{
oldPinGrpNodes.Add(node);
}
foreach (TreeNode node in oldPinGrpNodes)
{
if (newPinGrpNodes.Contains(node.Text)) continue; //this does not compile!
//How to do a check in the IF statement above?
//Continue with adding the unique pins to the newList
}
Or if you have any better idea please let me know!
have you tried the following Linq query, instead of your check?