KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have an event handler for a Textbox and a RichTextBox. The code is identical, but In handler #1 I do: RichTextBox tb = (RichTextBox)sender In handler #2 accordingly: TextBox tb = (TextBox)sender Doing so I can fully manipulate the sending control. How can I cast the sending object to Textbox or RichTextbox according to its type using sender.GetType().Name and then create the control at runtime and work with it? That way I only need one event handler function: less code, less errors, easier to maintain and DRY :-)
Tags (comma-separated)
Save Edits
Cancel