Getting protected controls using reflection
-
Hi, I am inspecting an assembly that has a form, and this form has some controls that are inherited from a BaseForm class. Using GetFields I get to know its controls. However, the inherited controls do not show. I have set BindingFlags as follows: BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic; Am I missing something, any ideas? Thanks in advance.
-
Hi, I am inspecting an assembly that has a form, and this form has some controls that are inherited from a BaseForm class. Using GetFields I get to know its controls. However, the inherited controls do not show. I have set BindingFlags as follows: BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic; Am I missing something, any ideas? Thanks in advance.
Try BindingFlags.FlattenHierarchy as well. Otherwise, I guess you'd have to get the fields on the base type(s) as well -- Type.BaseType Marc
People are just notoriously impossible. --DavidCrow
There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer
People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith