I have a problem on my coding. I want to add items to treeview by using regex and c#. But the problem is The nodes that are going to add have the same name.
The code ::
treeView1.Nodes.Clear();
string name;
TreeNode Root = new TreeNode();
RootNode.Text = "RootNode";
treeView1.Nodes.Add(RootNode);
MatchCollection ToGetPulinName = Regex.Matches(richtextbox1.Text,@"pulin (.*?)\{");
foreach (Match m in ToGetPulinName)
{
Group g = m.Groups[1];
name= g.Value;
TreeNode SecondRoot = new TreeNode();
SecondRoot.Text = "PulinRoot:"+pulinname;
RootNode.Nodes.Add(SecondRoot);
MatchCollection ToFoundIn = Regex.Matches(codingtxt.Text, @"pulin \w+{(.*?)}", RegexOptions.Singleline);
foreach (Match min in ToFoundIn)
{
Group gMin = min.Groups[1];
string gStr = gMin.Value;
string classname;
MatchCollection classnames = Regex.Matches(codingtxt.Text, @"class (.*?)\{", RegexOptions.IgnoreCase);
foreach (Match mis in classnames)
{
Group gmis = mis.Groups[1];
classname = gmis.Value;
TreeNode ClassRoot = new TreeNode();
ClassRoot.Text = "ClassRoot";
SecondRoot.Nodes.Add(ClassRoot);
}
}
}
The Result
Please help, Thanks.