Enum and sub classing
-
Ok, so I have a number of ‘modes’ for a control I wrote (List View: Detail, Large Icon, and so on). In the designer it is convenient to have an enumerator drop down, consisting of these modes, which a user can select. However, each mode is actually a subclass. So, I was wondering if there is some cool and/or strange way to have an enumerator that contains all subclasses found in the assembly/dlls. This would allow someone to add a new subclass with out also editing the enumerator containing the names of all the subclasses. Yes/No/Thoughts?
-
Ok, so I have a number of ‘modes’ for a control I wrote (List View: Detail, Large Icon, and so on). In the designer it is convenient to have an enumerator drop down, consisting of these modes, which a user can select. However, each mode is actually a subclass. So, I was wondering if there is some cool and/or strange way to have an enumerator that contains all subclasses found in the assembly/dlls. This would allow someone to add a new subclass with out also editing the enumerator containing the names of all the subclasses. Yes/No/Thoughts?
It is possible to do this using Reflection. Use the GetTypes() method on the Assembly class, iterate through the types and filter subclasses using the Type.IsSubClassOf() function. Regards Senthil