Save a properties name in a string, retrieve it again and execute it ?

MSFanboy used Ask the Experts™

I have several properties which return a Visibility status like Visible/Collapsed to drive my gui`s usercontrols to be shown or not.

now I have 10 Properties like:

public Visibility ChangeModule1VisibilityStatus{get;set;}
public Visibility ChangeModule2VisibilityStatus{get; set;}

then I have a class variable called

private static string _currentPropertyVisible;

Everytime I set a "ChangeModuleXXVisibilityStatus" property to Visible I want to save this property in the _currentPropertyVisible variable. So when I next time change a property again I set the last current Property to Collapsed saved/cached in the _currentPropertyVisible property.

How can I achieve that in a generic way -if possible- ?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
How about using an array of your "Visibility" properties (or maybe, if neccessary, an ArrayList to easier extend/shrink it) and store the index of current visible Property?
That way you can access the property itself by it's index from the array later on.
I know what you mean:

ChangeModule1Visibility Property has index 1 (in my mind determined...)
ChangeModule2Visibility Property has index 2
ChangeModule3Visibility Property has index 3

now I save the index of the current visible usercontrol in a static variable.

In the code where I set the visiblity.visible I know in my mind its lets say index 3 then I would collapse index 1,2,..,4,5... right? no... seems ugly.

What do you mean with arrarylist of visiblity?

could you share some code snippet please?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial