简体   繁体   English

扩展属性

[英]Extension Properties

HI, I Am creating one user Control in windows Application which contain Treeview With n Nodes 嗨,我要在Windows应用程序中创建一个用户控件,其中包含具有n个节点的Treeview
The NUmbe OF Nodes Will be decided At Runtime. NUmbe OF节点将在运行时确定。
I Want To Store Some Data On Each TreeNode Which I Can Retrieve When TreeNode Get Selected. 我想在每个TreeNode上存储一些数据,当选择TreeNode时可以检索这些数据。
Problem is that some node will store custid,custname.. 问题是某个节点将存储客户名称,客户名称。
some store studid,studname,,,,,, 一些商店研究过,studname ,,,,,,

I Have used Extension Methods 我已经使用了扩展方法
static class Extension 静态类扩展
{ {
static Dictionary m_Dictionary=new Dictionary(); 静态字典m_Dictionary = new Dictionary();
public static void SetTags(this TreeNode p_TreeNode, Dictionary p_Dictionary) 公共静态无效值SetTags(此TreeNode p_TreeNode,字典p_Dictionary)
{ {
m_Dictionary = p_Dictionary; m_Dictionary = p_Dictionary;
} }
public static Dictionary GetTags(this TreeNode p_TreeNode) 公共静态字典GetTags(this TreeNode p_TreeNode)
{ {
return m_Dictionary; 返回m_Dictionary;
} }
} }
but it will not help becase iam getting data on the last node only... 但这并不能帮助我仅在最后一个节点上获取数据...
how i can achieve this .. 我怎么能做到这一点..
is there is something like etension properties....or whether there is any other solution. 是否有诸如拉伸特性之类的东西……或是否有其他解决方案。
Thank In Advance,,,,,,, 预先感谢,,,,,,,

没有什么所谓的扩展属性存在,如果要向树节点添加简单的字符串数据,请使用Tag属性。

No, there's no such thing as of C# 3.0. 不,没有C#3.0之类的东西。

Look at this: https://stackoverflow.com/questions/138367/most-wanted-feature-for-c-4-0 看这个: https : //stackoverflow.com/questions/138367/most-wanted-feature-for-c-4-0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM