0

例子:

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).
4

0 回答 0