hello.
i get data from two database db1, db2, into one datagridview, this dtatgridview has three columns[Id, Name, DirectorId], only the first row has no director, and each Id has one or more child, so that i want to create treeview that have one main node, and each node can has one or more of childNode, for that, i declare :
.........
TreeNode tn = new TreeNode(this.DataGridView2.Rows[0].Cells[0].Value.ToString());
tn.Tag = this.DataGridView2.Rows[0].Cells[4].Value.ToString();
treeView1.Nodes.Add(settree(tn));
}
public TreeNode settree(TreeNode ns)
{
for (int i = 1; i <= this.DataGridView2.Rows.Count-1; i++)
{
if (this.DataGridView2.Rows[i].Cells[5].Value.ToString() == ns.Tag.ToString())
{
var node = new TreeNode(this.DataGridView2.Rows[i].Cells[0].Value.ToString());
node.Tag = this.DataGridView2.Rows[i].Cells[4].Value.ToString();
node.Nodes.Add(settree(node));
return node;
}
else { return ns; }
} }
where cell[0] for name, cell[4] for id, cell[5] for directorId.
I suppose that this code is suitable, but i have error, that i can not solve it.
when i apply this code, i get error message that tell me:(not all code paths return a value) at settree() method;
can you help me?
thank you