在我的问题上,我想通过反射来检索一些值。 现在我想要设置值的对象感谢反射。是否可以从PropertyInfo获取“对象”?
我想这样写:
private void AppliquerColonnesPersonnalisation(Control control, Propriete propriete, PropertyInfo Info)
{
UltraGrid grille = (UltraGrid)control;
SortedList<int,string> sortedOrderedColumns = new SortedList<int,string>();
if (grille != null)
{
// I want to write MapPropertyInfo method
ColumnsCollection cols = MapPropertyInfo(Info);
的PropertyInfo包含一个类型ColumnsCollection的。我只是想将我的PropertyInfo“映射”到一个对象以定义一些属性后:例如:
cols[prop.Nom].Hidden = false;
是否有可能?
最好的问候,
弗洛里安
编辑:我试过GenericTypeTea解决方案,但我有一些问题。在这里我的代码片段:
private void AppliquerColonnesPersonnalisation(Control control, Propriete propriete, PropertyInfo Info)
{
UltraGrid grille = (UltraGrid)control;
ColumnsCollection c = grille.DisplayLayout.Bands[0].Columns;
// Throw a not match System.Reflection.TargetException
ColumnsCollection test = Info.GetValue(c,null) as ColumnsCollection;
SortedList<int,string> sortedOrderedColumns = new SortedList<int,string>();
但TargetException抛出
你能告诉我们你得到'Info'的代码吗? – GenericTypeTea 2010-07-05 14:38:38