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

  • SEARCH
  • Home
  • 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 3594070
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T19:39:44+00:00 2026-05-18T19:39:44+00:00

I’m new in C# but not new to coding –being doing it for almost

  • 0

I’m new in C# but not new to coding –being doing it for almost two decades–, and have a problem with properties in a custom control I’m building, which inherits from a Panel. When I put my properties, I can see them in the Designer properties list and can even set them, but when running my little application, it seems these properties values are not used. The same if I change a property programatically: no error but my control does nothing, it is like they are not properly set. However, if I do it programatically whithin the class, they do work. My guess is that something in my properties set/get stuff is not right. Please see the following code chunk of how I’m doing it:

public class ColorStrip : Panel
{
    // properties
    // ------------------------------------------
    // size of color clusters (boxes)
    private int _clusterSize = 20;
    // controls if show the buttons panel
    private Boolean _showButtons;

    // property setters/getters
    // ------------------------------------------
    // clusterSize...
    public int clusterSize
    {
        get { return _clusterSize; }
        set { _clusterSize = value; }
    }
    // showButtons...
    public Boolean showButtons
    {
        get { return _showButtons; }
        set { Console.Write(_showButtons); _showButtons = value; }
    }
    ....

So in my form, for instance in the load or even in a click event somewhere, if I put colorStrip1.showButtons = false; or colorStrip1.showButtons = true; whatever (colorStrip1 would be the instance name after placing the control in the form in design mode)… console.write says always ‘false’; Even if I set it in the design properties list as ‘true’ it will not reflect the settled value, even if I default it to true, it will never change externally. Any ideas? Non of the methods get the new and externally settled property value neither, obviously the getter/setter thing is not working. Seems to me I’m not doing right the way I set or get my properties outside the class. It works only inside it, as a charm…Any help…very appreciate!

Cheers

lithium

p.s. TO CLARIFY SOLUTION:

Setting the property in this case didn’t work because I was trying to use a new set value within the constructor, which seems can’t get the new values since it is, well, building the thing. If I change the property value in Design mode > Property editor or in code externally to the object, say in it’s parent form’s load event, it will change it but readable for all methods except the constructor, of course 🙂

  • 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-05-18T19:39:44+00:00Added an answer on May 18, 2026 at 7:39 pm

    It’s likely an issue of the order of execution. Your property setter just sets a variable, but doesn’t actually trigger anything on the control to update the state related to this variable (e.g. adding or showing the buttons I assume).

    When you set the property befre the rest of the initialization is done, the value is being used, otherwise it isn’t because during the initial go the default value is still the property value.

    You need to act on the setter, here’s some pseudocode to illustrate:

    set {
      _showButtons = value;
      if (alreadyInitialized) {
        UpdateButtons();
      }
    }
    

    Note: make sure to first set the value, then act – otherwise you end up using the old value (just like your Console.Write() is doing).

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

Sidebar

Related Questions

No related questions found

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.