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

后端 未结 2 1616
栀梦
栀梦 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

    0 讨论(0)
  • 2021-01-15 04:31

    In view of your most recent edit:

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

    It can't. For some reason, the former employee wanted both propertyA and propertyB to be the same or there is a typo, and this is in actual fact a bug of some sort.

    0 讨论(0)
提交回复
热议问题