从与其关联的树节点访问对象属性?
你好, 我已阅读 轻松对象绑定到 Treeview 节点, 但仍有未解答的问题。
如果一个对象与树节点标记属性关联,如何从该树节点访问该对象成员/属性?
node1 = new TreeNode();
node1.tag = object1;
//ex:if object1 has public property valueA
//How to access valueA from node1 ??
Hallo,
I have read Easy object binding to Treeview Node,
but still have unanswered question.
if an object is associated with treenode tag property, how to access that object members/properties from that treenode ?
node1 = new TreeNode();
node1.tag = object1;
//ex:if object1 has public property valueA
//How to access valueA from node1 ??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许你可以将其转换回 object1 类型...
Maybe you can cast it back to the object1 type...
如果您不知道相关对象的类型,那么您可以使用 System.Reflection:
最后,如果您想知道属性的名称,请再次使用 System.Reflection 来救援:
If you don't know the type of the object in question, then you can use System.Reflection:
Finally, if you want to know the names of the properties, again System.Reflection to the rescue: