使用xmlrpc获取所有内容时如何在Treeview中添加类别?C# [英] how to add categories in treeview when get all with xmlrpc?c#
本文介绍了使用xmlrpc获取所有内容时如何在Treeview中添加类别?C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Treeview(父级和子级)中添加类别
我可以使用此代码添加父对象".
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);
}
}
}
}
但是我遇到了错误(指定的参数超出了有效值的范围.参数名称:index).我该如何解决?
but i catch error (Specified argument was out of the range of valid values.parameter name: index) .how i can solve it ?
推荐答案
我认为这是您的问题
I think this is your problem
tvCat.Nodes[i].Nodes.Add(cat[j].categoryName);
您没有i
的tvCat.Nodes
编号,这就是它抛出的原因.
我想.
/Fredrik
You don''t have i
number of tvCat.Nodes
and that''s why it''s throwing.
I think.
/Fredrik
所以,我如何在树状视图中与孩子和父母一起添加类别?
so ,how i can add categories in treeview with child and parents ?
有人可以帮助我吗?!
这篇关于使用xmlrpc获取所有内容时如何在Treeview中添加类别?C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文