How can Property Descriptor gets values of two controls using same code line?

后端 未结 2 1615
栀梦
栀梦 2021-01-15 04:22

I found this code in one of the project developed by an Ex-Employee for custom gridview with custom controls which works fine but I am not sure what exactly it is doing,

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-15 04:30

    GetValue(control.NamingContainer, this._PropertyAField, ref propertyA)
    

    ProperyA is given as a reference therefor everything that happens to propertyA inside that method will update propertyA that was defined above.

    using

    PropertyDescriptor propertyA = null;
    

    instead of

    PropertyDescriptor propertyA = TypeDescriptor.GetProperties(DataBinder.GetDataItem(control.NamingContainer)).Find("boundField", true);
    

    will still work.

    Further Reading
    ref method parameter keyword

提交回复
热议问题