标签和树视图节点 [英] Tags and Treeview nodes

查看:96
本文介绍了标签和树视图节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以向我解释标签的正确用法.我以为这只是对节点的引用.这样您就可以查找它们或其他内容.我在这里想念什么吗?

< pre>
字符串[] AuthorNames =新字符串[bookdbDataSet.Tables [0] .Rows.Count];
int row = 0;
foreach(bookdbDataSet.Tables [0] .Rows中的DataRow行)
{
AuthorNames [row] = Row ["AuthorFirst"].ToString()+" + Row ["AuthorLast"].ToString();
TreeNode tn = new TreeNode(Row ["AuthorLast"].ToString()+'',''+ Row ["AuthorFirst"].ToString());
tn.Tag ="2"
rootNode.Nodes.Add(tn);

行++;
}
</pre>


每当我出于某种原因从树视图中获取并执行一个selectnode时,即使我以为我将其设置为2,标记也始终为null ...我不是标记的用途是什么?如果可以的话,请向我解释我可能做错了什么.非常感谢董事会为我提供的所有帮助.

Can someone explain to me the proper use of tags. I was thinking it was just that a reference to the node. so you can look them up or whatever. Am I missing something here?

<pre>
string[] AuthorNames = new string[bookdbDataSet.Tables[0].Rows.Count];
int row=0;
foreach (DataRow Row in bookdbDataSet.Tables[0].Rows)
{
AuthorNames[row] = Row["AuthorFirst"].ToString() + " " + Row["AuthorLast"].ToString();
TreeNode tn = new TreeNode(Row["AuthorLast"].ToString() + '','' + Row["AuthorFirst"].ToString());
tn.Tag ="2"
rootNode.Nodes.Add(tn);

row++;
}
</pre>


whenever I take and do a selectnode from the treeview for some reason the tag is always null even though I thought I was setting it to the value of 2... I that not what the tag is for ? If it is could you please explain to me what i might be doing wrong. thank you so much for all the help this board has given me.

推荐答案

请参见
尝试tn.Tag = Row["AuthorFirst"]看看是否有效.
See here.

As per the link, "Any Object derived type can be assigned to this property".

Try tn.Tag = Row["AuthorFirst"] to see if it works.


这篇关于标签和树视图节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆