如何在树视图后面添加 ID?代码:string players = "Name:Peter ID:1 Name:karl ID:2 Name:max ID:3 Name:Nils ID:4";var user = players.split().Where(a => a.StartWith("Name:")).ToList();var ID = players.split().Where(a => a.StartWith("ID:")).ToList();for(int i= 0; i<user.Count(); i++) { var pl = user[i].Substring(user[i].IndexOf(":") + 1); var plid = ID[i].Substring(ID[i].IndexOf(":") + 1); treeView1.Nodes.Add(pl);}现在,如果选择用户,我想在文本框中显示 ID编辑:我试过了treeView1.Tag = plid;但这不起作用..
1 回答
手掌心
TA贡献1942条经验 获得超3个赞
考虑这个模式:
for(int i= 0; i<user.Count(); i++) {
TreeNode tn = new TreeNode();
tn.Text = "The name";
tn.Tag = "The ID";
treeView1.Nodes.Add(tn);
}
- 1 回答
- 0 关注
- 174 浏览
添加回答
举报
0/150
提交
取消