Text color on disabled label control

Maybe this is kind of a silly question, but I have a problem with changing the color of the text in disabled label control. It must be disabled, but I want not to be grey and not to be in 3D (I want to be flat text, without shades). Any help will be appreciated.

Thanks in advance...
MilanJAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tomvergoteCommented:
are you sure it's a label and not a linklabel or a button or something?
Are you talking about webforms or winforms?
0
Chester_M_RagelCommented:
And why you want to make a label dissabled?
0
MilanJAuthor Commented:
It is a label, but I tried a linklabel that has property "Disabled Link Color", and  it ignores my text color also (it is also grey and with shades). With linklabel I tried this in InitializeComponent:

this.lblReport.Enabled = false;
this.lblReport.DisabledLinkColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(102)));

I'm talking about winforms.

I want to make label disabled because it is on the panel, and when mouse comes over the label (and label is enabled) my panel looses focus, and I need focus on my panel all the time because you can click on panel all the time (some kind simulation of a button, but a bit more complex one).

Maybe my english is not good, but I think you can understand what I mean.  
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Chester_M_RagelCommented:
You could override OnPaint in a derived class and handle drawing the text string in your override, thus allowing you to use whatever color you wanted to use.

For example a custom label control,

using System;
using System.Drawing;
using System.Windows.Forms;

namespace MyNameSpace
{
      /// <summary>
      /// Summary description for Class1.
      /// </summary>
      public class MyLabel : Label
      {
            protected override void OnPaint(PaintEventArgs e)
            {
                  
                  Brush br = new SolidBrush(Color.Blue);
                  e.Graphics.DrawString(this.Text,this.Font,br,this.ClientRectangle);
            }

            public MyLabel()
            {
                  //
                  // TODO: Add constructor logic here
                  //
            }
      }
}

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MilanJAuthor Commented:
@Chester M Regal
Thanks, but when I do that, I cannot see my form in design view (although this solution works just fine when I start the project), but this is (from my point of view) normal behaviour because I destroy its original OnPaint.

But, I came out with another solution, and I think this will work fine, too (and it doesn't break down the design view):

In InitializeComponent:
this.lblReport.Paint += new System.Windows.Forms.PaintEventHandle(this.lblReport_Paint);

and then:
private void lblReport_Paint(object sender, PaintEventArgs e)
{
    Brush br = new SolidBrush(Color.Red);
    e.Graphics.DrawString(this.lblReport.Text, this.lblReport.Font,br, this.lblReport.ClientRectangle);
}

What do you think?
0
Chester_M_RagelCommented:
>Thanks, but when I do that, I cannot see my form in design view (although this solution works just fine when I start the >project), but this is (from my point of view) normal behaviour because I destroy its original OnPaint.

>But, I came out with another solution, and I think this will work fine, too (and it doesn't break down the design view):
If you create that in a new project you can get the view..


>In InitializeComponent:
>this.lblReport.Paint += new System.Windows.Forms.PaintEventHandle(this.lblReport_Paint);

>and then:
>private void lblReport_Paint(object sender, PaintEventArgs e)
>{
>   Brush br = new SolidBrush(Color.Red);
>    e.Graphics.DrawString(this.lblReport.Text, this.lblReport.Font,br, this.lblReport.ClientRectangle);
>}
>
>What do you think?

This is another way(easy:)) of achiving the same task.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.