C# 如何使用betfair api中接收到的给定路径浇注树状视图?
我正在c#windows窗体应用程序中使用betfair API 当我调用getAllMarket()方法时,我得到一个长字符串,其中包含一系列类似以下的路径:C# 如何使用betfair api中接收到的给定路径浇注树状视图?,c#,winforms,treeview,betfair,C#,Winforms,Treeview,Betfair,我正在c#windows窗体应用程序中使用betfair API 当我调用getAllMarket()方法时,我得到一个长字符串,其中包含一系列类似以下的路径: ~\Cricket\Group C\England v South Africa\Test Series~ ~\Cricket\Group C\English Domestic\Clydesdale Bank 40 2012\Group Winners~ ~\Cricket\Group C\England v South Afri
~\Cricket\Group C\England v South Africa\Test Series~
~\Cricket\Group C\English Domestic\Clydesdale Bank 40 2012\Group Winners~
~\Cricket\Group C\England v South Africa\Test Series\England v South Africa (2nd Test)~
step 1>Check if the path already exixts, then select the last node on the path,
step 2>else create the whole path and select the last node,
step 3> add a custom child node to he selected last node of the path,
所以我想根据如下路径填充treeview控件:
~\Cricket\Group C\England v South Africa\Test Series~
~\Cricket\Group C\English Domestic\Clydesdale Bank 40 2012\Group Winners~
~\Cricket\Group C\England v South Africa\Test Series\England v South Africa (2nd Test)~
step 1>Check if the path already exixts, then select the last node on the path,
step 2>else create the whole path and select the last node,
step 3> add a custom child node to he selected last node of the path,
我以前从未使用过treeviews,但现在已经学习了基本知识,并且自定义子节点也已经创建,因此详细的答案将非常有用,thanxx提前这是针对wpf的,因此在windows窗体中,代码应该是
List<string> mylist = market.Trim('~').Split(new string[] { @"\" }, StringSplitOptions.RemoveEmptyEntries).ToList();
if (mylist.Count > 0)
{
TreeNode root = new TreeNode(mylist[0]);
treeView1.Nodes.Add(root);
mylist.RemoveAt(0);
TreeNode temp = root;
foreach (string s in mylist)
{
temp = AddNode(temp, s);
}
treeView1.SelectedNode = root;
}
哦…那代码看起来不错…伊玛去检查一下它是否对我有效…thanxxx很多…:哎呀,这个treeviewitem东西对windows窗体不起作用…:/该代码已更新到windows窗体,但下次请您指定平台抱歉,如果不清楚,但我提到我正在使用windows应用程序,neways..你的代码工作起来很有魅力,我自己设法修改了它,只做了几处修改,就完全符合我的要求了。。。。谢谢,先生:)