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 7708423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:36:31+00:00 2026-06-01T00:36:31+00:00

A winclient is using GUI controls (BaseForm, BaseTextBox, BaseComboBox) from a separate GUI project

  • 0

A winclient is using GUI controls (BaseForm, BaseTextBox, BaseComboBox) from a separate GUI project which is used in other projects as well

These controls change backgroundcolor to yellow-ish when they are focused and retains their old backgroundcolor when focus leaves. (onEnter and OnLeave events)

Now, this winclient will let the users choose their own focus color. I know I can directly set the “FocusColor” property on all the controls but that’s not what i want (there’s a lot of controls)

What’s the best approach? I thought maybe I could inject some kind of “CustomColorProvider” into the controls and rewrite the GUI project to fetch the focuscolor from a “StandardColorProvider”. But I don’t exactly how these controls should get their “CustomColorProvider” injected. (I’m not so experienced with DI) The controls are added via the designer and the creation of controls is by auto-generated code “partial designer class”

Or maybe I should just write new controls in this specific winclient which inherits from the GUI project and then override the methods where the focuscolor is set?

I have access and allowed to modify both the winclient and the GUI project.

  • 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. Editorial Team
    Editorial Team
    2026-06-01T00:36:33+00:00Added an answer on June 1, 2026 at 12:36 am

    As you mentioned, I would use the Decorator pattern, passing a different concrete decorator depending on how you want to extend the control. You can find an example here.

    EDIT:

    Declare an interface IControlExtender

    public interface IControlExtender
    {
        Color BackColor { get; }
        Color HighlightColor { get; }
    }
    

    Create a default implementation

    class DefaultExtender : IControlExtender
    {
        public Color BackColor
        {
            get { return Color.Yellow; }
        }
    
        public Color HighlightColor
        {
            get { return Color.Red; }
        }
    }
    

    Add a property to your GUI control

    IControlExtender _extender = new DefaultExtender();
    public IControlExtender Extender
    {
        get { return _extender; }
        set
        {
            if ((value != null) && (value != _extender))
            {
                _extender = value;
                RefreshControl();
            }
        }
    }
    
    void RefreshControl()
    {
        this.BackColor = Extender.BackColor;
    }
    

    Create any new implementations, such as

    class CustomExtender:IControlExtender
    {
        public Color BackColor
        {
            get { return Color.Green; }
        }
    
        public Color HighlightColor
        {
            get { return Color.Pink; }
        }
    }
    

    And override the default as you need

    public Form1()
    {
        InitializeComponent();
        control1.Extender = new CustomExtender();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a WP7 app which gets website information using WebClient 's DownloadStringAsync method.
Opening a public page from browser works fine. Downloading same page using WebClient throws
I am using Google's Annotated Time Line tool to plot data which spans over
I am using the code below to download multiple attachments from a TFS server:
Hail! I want to fetch image from NOT PUBLIC Google Site's page. I'm using
I am new to Silverlight. In Silverlight, we can get data from server using
I am working on a application which downloads using 1) Parallel.ForEach(linklist, x => DownloadAsync(x));
I'm using WebClient to download some text from a web-page, like this: WebClient wc
I'm parsing data from an xml file using WebClient. In DownloadStringCompleted method I have
I'm trying to download zend-framework (from http://framework.zend.com/releases/ZendFramework-1.11.11/ZendFramework-1.11.11.zip ) simply using WebClient string url =

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.