C#,BindingSource和DataSource

时间:2012-09-09 15:21:48

标签: c# reflection bindingsource

示例:

public class MyProperty
{
     //something..
}

public class MyClass
{
    private MyProperty[] myProperty = null; 
    public MyProperty[] myProperty
      {
        get
            { 
             //execute some code
             return myProperty;
            }
        set
            { 
             myProperty = value;
            }
      }
}


MyClass testMyClass = new MyClass();
myBindingSource.DataSource = testMyClass.MyProperty;

有没有办法,可能使用反射(或继承自BindingSource)来获取对MyClass.MyProperty实例的引用,而不是仅包含MyProperty []的对象。

BindingSource.DataSource只返回某些对象,可以转换为某些 MyProperty数组。

生成的结果应该达到这种情况:

BindingSource.DataSource = GeneratedResult;  //execute some code (from the get).

0 个答案:

没有答案
相关问题