Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 141851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:50:34+00:00 2026-05-11T07:50:34+00:00

I’ve made it a personal rule to inherit every UI control before using it.

  • 0

I’ve made it a personal rule to inherit every UI control before using it. In a previous life I’d always considered this one of the less useful things you could do because the justification always seemed to be ‘I might want to change the font on all the buttons at once’… a motivation that never paid off… once… ever.

Two recent projects have changed my mind about the practice, though. In the first, we needed a consistent ‘ValueChanged’ event so that we could easily implement a ‘dirty’ flag on our forms without a massive switch statement to choose between a Textbox’s ‘TextChanged’ event, or a ListBox’s ‘SelectedIndexChanged’ etc. We just wanted one consistent thing to listen for on all controls, and subclassing the built-in controls bought us that pretty easily.

In the second project, every effort was made to get by with the base controls because the UI was expected to be pretty simple, but a few months in, it became obvious that they just weren’t going to cut it anymore, and we purchased the Telerik control suite. If we had inherited all the controls to begin with, then changing our derived controls to inherit from the Telerik controls would have applied the changes for us globally. Instead, we had to do some searching and replacing in all the form designers.

So here’s my question: What are the relative strengths and weaknesses of

  1. Simply adding a Class, and making it inherit from a control.
  2. Adding a new ‘Custom Control’ and inheriting.
  3. Adding a new ‘Component’ and inheriting.

All three have the same effect in the end, you get a new type of Button to put on your forms. I’ve seen all three used by different people, and everyone seems to think that their way is the best. I thought I should put this discussion on StackOverflow, and maybe we can nail down a concensus as a community as to which one is the ‘right’ way.

Note: I already have my personal opinion of which is ‘right’, but I want to see what the world thinks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T07:50:35+00:00Added an answer on May 11, 2026 at 7:50 am

    If both 1 & 2 are inheriting, then they are functionally identical, no? Should one of them be encapsulating a control? In which case you have a lot of pass-thru members to add. I wouldn’t recommend it.

    Peronally, I simply wouldn’t add extra inheritance without a very good reason… for example, the ‘changed event’ could perhaps have been handled with some overloads etc. With C# 3.0 this gets even cleaner thanks to extension methods – i.e. you can have things like:

    public static AddChangeHandler(         this TextBox textbox, EventHandler handler) {     testbox.TextChanged += handler; } public static AddChangeHandler(         this SomethingElse control, EventHandler handler) {     control.Whatever += handler; } 

    and just use myControl.AddChangeHandler(handler); (relying on the static type of myControl to resolve the appropriate extension method).

    Of course, you could take a step back and listen to events on your own model, not the UI – let the UI update the model in a basic way, and have logic in your own object model (that has nothing to do with controls).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 142k
  • Answers 142k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Citing Wikipedia: In addition to loss of significance, inability to… May 12, 2026 at 8:17 am
  • Editorial Team
    Editorial Team added an answer Usually the session ID won't be read from POST. You… May 12, 2026 at 8:17 am
  • Editorial Team
    Editorial Team added an answer It depends a lot on what your "radar" needs to… May 12, 2026 at 8:17 am

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.