Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
2
Reply
Lookup constants based on object names
Simon Bennetts
Jan 28 2014 10:57 AM
822
Reply
Hi,
I have a windows application which places default / help values in empty text boxes on the form in gray to show the user what is supposed to be entered (e.g. FORENAME in my txtForename textbox) in the textbox.
I have a generic event for all my textboxes on Enter to remove the text, change back from gray and add the change event. On exit, I'm checking if they've entered anything and would like to refill the textbox with it's default value if they've left it blank or delete it later.
I have a ParametersDefaults class which contains a list of constants with the same name as the text box objects (e.g. public const string txtForename = "FORENAME").
What I want to do is get that string value based on the sender object (which will always be a text box).
Something along the lines of
((TextBox)sender).Text = DefaultParameters.[sender.Name bit goes here!]
I'm sure there must be an easy way but I can't figure it out and it's only Tuesday!
Thanks in advance
Simon
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
Define a base class called animal with following members:
delete row from gridview and database