|
hi
how to add categories in treeview(parent and child)
i can Add Parent with this code .
WordPressWrapper ww = new WordPressWrapper(textBox2.Text, textBox3.Text, textBox4.Text);
var cat = ww.GetCategories();
for (int i = 0; i < cat.Count; i++)
{
if (cat[i].parentId == "0")
{
TreeNode tn = new TreeNode(cat[i].categoryName);
tn.ForeColor = Color.Blue;
tvCat.Nodes.Add(tn);
this is working good . (i have not any problem for add parent) . for add child i writhe this code .
for (int i = 0; i < cat.Count; i++) { if (cat[i].parentId != "0") { for (int j = 0; j < cat.Count; j++) { if (cat[i].parentId == cat[j].categoryId) { tvCat.Nodes[i].Nodes.Add(cat[j].categoryName); } } } }
but i catch error (Specified argument was out of the range of valid values.parameter name: index) .how i can solve it ?
|