twcadmin
asked on
Mimic System.Drawing.Color
I'm trying to mimic System.Drawing.Color in that I want to have a class that can return different acceptable values. I have a custom web control and one of the properties that the user can set is PageType. I keep forgetting the values that the control has stored so I want to be able to do something like
MyControl.PageType = CustomPageTypes.HomePage
Right now I do MyControl.PageType = "HomePage" to pass a string as the value but I want to be able to mimic System.Drawing.Color (e.g. for red you can assign System.Drawing.Color.Red)
Working in VB.NET but C# is also acceptable.
MyControl.PageType = CustomPageTypes.HomePage
Right now I do MyControl.PageType = "HomePage" to pass a string as the value but I want to be able to mimic System.Drawing.Color (e.g. for red you can assign System.Drawing.Color.Red)
Working in VB.NET but C# is also acceptable.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oops.
Then set the type of PageType to this enum.
If you are using C# then jensfiederer's example would work. If VB.NET then mine.
Then set the type of PageType to this enum.
If you are using C# then jensfiederer's example would work. If VB.NET then mine.
ASKER
Althought both methods can work in different ways, I revoke my choice of using Structure since the experts suggestions of using Enum was the ultimate solution to my problem and I am now using Enum
ASKER
http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/5dcb5832-bcba-4f3b-a892-1f7c25541cef/
Code below where Person is actually what i'm trying to refer to as CustomPageTypes
and the properties that are currently set as names would be renamed as my page types (e.g. HomePage)
Open in new window