I have an abstract class that is a windows form called "BaseList" that
contains a grid control. This grid control is then populated by any
concrete class that inherits from BaseList. I have a class SpecificList
class that is a kind of BaseList (class SpecificList:BaseList). When a
user interacts with the SpecificList, they will be allowed to save the
layout of that grid. Now, here's the rub.
I want to put the code into BaseList for storing the layout of the grid.
But I need to store the layout uniquely for each instance of BaseList.
In other words if I want to save the layout of SpecificList, the code
executed in BaseList needs to know the name of the concrete class that
instantiated it (SpecificList). Likewise if I had AnotherList:BaseList,
then when a user saves the layout of AnotherList, the code inside of
BaseList needs a way to get the string "AnotherList" out.
My thought is to add an abstract method to BaseList called
"GetConcreteClassName" or something like that. This would then force
all the subclasses of BaseList to implement the method. I believe that
there must be a more elegant solution than that. I would have to
believe that I could use reflection, but I'm not sure if this is a wise
approach or not. Is there a more OO way to figure this out?
Thanks,
Bill Gregg
*** Sent via Developersdex http://www.developersdex.com ***