簡體   English   中英

C#在樹視圖后面創建一個ID

[英]c# make a ID behind a treeview

如何在樹視圖后面添加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;

但這不行..

考慮以下模式:

for(int i= 0; i<user.Count(); i++) {

    TreeNode tn = new TreeNode();
    tn.Text = "The name";
    tn.Tag = "The ID";
    treeView1.Nodes.Add(tn);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM