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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:36:01+00:00 2026-05-30T07:36:01+00:00

I have a MLable which inherit Label . It’s backcolor is red. I can

  • 0

I have a MLable which inherit Label . It’s backcolor is red. I can use it on forms with red background. But when i want to change background to black from MLabel customcontrol, already added labeles doesn’t effect. Only new MLabel’s background black, others red. What the ???

Should i have to change them one by one?

SAMPLE CODE:

MLabel.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TestCControl
{
    public partial class CustomControl1 : Label
    {
        public CustomControl1()
        {
            InitializeComponent();
        }

        protected override void OnPaint(PaintEventArgs pe)
        {
            base.OnPaint(pe);
        }
    }
}

Form1.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TestCControl
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
    }
}

Form1.Designer.cs

namespace TestCControl
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.customControl11 = new TestCControl.CustomControl1();
            this.customControl12 = new TestCControl.CustomControl1();
            this.SuspendLayout();
            // 
            // customControl11
            // 
            this.customControl11.AutoSize = true;
            this.customControl11.BackColor = System.Drawing.Color.Black;
            this.customControl11.Location = new System.Drawing.Point(50, 23);
            this.customControl11.Name = "customControl11";
            this.customControl11.Size = new System.Drawing.Size(86, 13);
            this.customControl11.TabIndex = 0;
            this.customControl11.Text = "customControl11";
            // 
            // customControl12
            // 
            this.customControl12.AutoSize = true;
            this.customControl12.BackColor = System.Drawing.Color.Maroon;
            this.customControl12.Location = new System.Drawing.Point(140, 74);
            this.customControl12.Name = "customControl12";
            this.customControl12.Size = new System.Drawing.Size(86, 13);
            this.customControl12.TabIndex = 1;
            this.customControl12.Text = "customControl12";
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(284, 262);
            this.Controls.Add(this.customControl12);
            this.Controls.Add(this.customControl11);
            this.Name = "Form1";
            this.Text = "Form1";
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private CustomControl1 customControl11;
        private CustomControl1 customControl12;
    }
}

As you can see one of the custom control has black other maroon backcolor. Changes on MLabel doesn’t effect previously added controls on winform.

  • 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-30T07:36:02+00:00Added an answer on May 30, 2026 at 7:36 am

    A couple things to check here.

    Are all of your MLabels referring to the same version? (probably)

    How are you setting background of the MLabel control, is it a change to the default background color?

    How are you changing the existing MLabels, are you setting them manually in the code, or are you relying on the default background color?

    Also, check your winform code. If the designer code sets the MLabel background color explicitly, then this will override any defaults the control may have. If that is the case, then you will need to either remove the background color setting so that it uses the default, or you will have to change each one manually.

    If the above all seems correct, then some code and/or a little more information would be useful here.

    Updated Answer after seeing actual code:

    In CustomControl1 you will want to do something like this:

     System.Drawing.Color _backColor = System.
     protected override System.Drawing.Color BackColor 
     {
         get{return _backColor;} 
         set{_backColor = value;}
     }
    

    In the Form1.Designer.cs remove the lines that set the BackColor. These are explicitly setting the backcolor and not allowing a default color

    this.customControl11.BackColor = System.Drawing.Color.Black;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have an app that can use tts to read text messages. It can also
I have a label which pops up displaying points in my application. I am
Have just started using Visual Studio Professional's built-in unit testing features, which as I
Have converted devise new session from erb to Haml but doens't work, this is
Have searched the database but need to specifically sum(of hours flown or days off)in
have anyone can tell me what syntax error on this actionscript (actionscript3.0)? var rotY:
I have two sliders in my view and I want to get both value
Have finally got a responsive site working (of a fashion). What I want to
Have a problem that seems easy on paper but i'm having a big problem
Have a linking (or ref) table which has a dual primary key. Need to

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.