Link to home
Start Free TrialLog in
Avatar of MilanJ
MilanJ

asked on

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...
Avatar of tomvergote
tomvergote
Flag of United States of America image

are you sure it's a label and not a linklabel or a button or something?
Are you talking about webforms or winforms?
Avatar of Chester_M_Ragel
Chester_M_Ragel

And why you want to make a label dissabled?
Avatar of MilanJ

ASKER

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.  
ASKER CERTIFIED SOLUTION
Avatar of Chester_M_Ragel
Chester_M_Ragel

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MilanJ

ASKER

@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?
>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.