hello.
I had xml file that has node its attribute are ( name , id , sex, child , father). fathe refer to id of father, only the first xmlnode has attribute father with 0 value.
Now i want to create treeview in c#, so each xmlnode has treenode, and each father treenode has child treenode as in xml file.
namespace Fulltree
{
public partial class Form1 : Form
{
public struct person
{
public string id;
public string name;
public string father;
public string child;
}
XDocument xmldoc = XDocument.Parse(Fulltree.Properties.Resources.index);
person[] arr = new person[200];
TreeNode[] tn = new TreeNode[200];
public Form1()
{
InitializeComponent();
setlist();
createtree();
}
public void setlist()
{
int i = 0;
while (i < 200) {
var str = (from n in xmldoc.Descendants("grand")
where n.Attribute("id").Value == (i+1).ToString()
select new
{
Name = n.Attribute("name").Value,
Sex = n.Attribute("sex").Value,
Status = n.Attribute("status").Value,
Child = n.Attribute("child").Value,
Id = n.Attribute("id").Value,
Father = n.Attribute("father").Value
}).First();
{
arr[i].id = str.Id.ToString();
arr[i].child = str.Child.ToString();
arr[i].name = str.Name.ToString();
arr[i].father = str.Father.ToString();
tn[i] = new TreeNode(str.Id);
tn[i].Text = str.Name.ToString();
}
i+=1;
}// end while
} //end setlist
public void createtree()
{ AddAllChildren(arr[0], 0); } ---------------------------------------------------------line01
public void AddAllChildren( person[] arr , int parentIndex ) {
for (int childIndex = parentIndex+1; childIndex < arr.Length; ++childIndex){
if( arr[childIndex].father == arr[parentIndex].id ) {
tn[parentIndex].Nodes.Add(tn[childIndex]);
AddAllChildren( arr[childIndex], childIndex );-----------------------------------------line02
} } } } }
but i got this msgs:
Error 102 The best overloaded method match for 'Fulltree.Form1.AddAllChildren(Fulltree.Form1.person[], int)' has some invalid arguments
Error 103 Argument 1: cannot convert from 'Fulltree.Form1.person' to 'Fulltree.Form1.person[]'
Error 104 The best overloaded method match for 'Fulltree.Form1.AddAllChildren(Fulltree.Form1.person[], int)' has some invalid arguments
Error 105 Argument 1: cannot convert from 'Fulltree.Form1.person' to 'Fulltree.Form1.person[]'
thanks for all