RadLabel ForeColor still gray after reenabled

5 posts, 0 answers
  1. Chris Ward
    Chris Ward avatar
    52 posts
    Member since:
    Jan 2010

    Posted 10 Nov 2014 Link to this post

    When a RadLabel enters the disabled state the fore color changes to gray. However, when the RadLabel is re-enabled the fore color does not return to it's former glory, rather it stays gray forever.

    I can't seem to override this behavior even with a custom theme.

    Edit: I tried setting the forecolor in radLabel1_EnabledChanged, but it never fired. The problem seems to be that when a RadLabel parent's Enabled flag is set to true, the RadLabel itself is never notified of the event.

    If I manually set ".Enabled = true;" for every label on my form, they restore their original ForeColors as expected.

    The RadLabel is in a SplitPanel which is in a RadSplitContainer, where the RadSplitContainer is the control being disabled / enabled.
  2. Chris Ward
    Chris Ward avatar
    52 posts
    Member since:
    Jan 2010

    Posted 10 Nov 2014 Link to this post

    I was almost certain I had reported this bug in the past (2 years ago), but I couldn't find the post. Here it is:
    http://www.telerik.com/forums/radlabel-style-bug#xrvUzMPkQEGNPDhKcb4IdQ

    Contrary to what was suggested there, this issue has not been resolved in the latest version as far as I can tell.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. George
    Admin
    George avatar
    500 posts

    Posted 13 Nov 2014 Link to this post

    Hello Chris,

    Thank you for writing.

    I was not able to reproduce the scenario you are describing on my end. You can find my sample project attached below. It is setup by your instructions. Please, take a look at it and let me know if there is anything that I am missing.

    Looking forward to your reply.

    Regards,
    George
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  5. Chris Ward
    Chris Ward avatar
    52 posts
    Member since:
    Jan 2010

    Posted 13 Nov 2014 Link to this post

    Hmm, so it appears this is actually a theme issue.

    If I use a theme, i.e. VisualStudio2012Light, then any ForeColor I set in the designer is overridden by the theme's RadLabelElement.ForeColor. In an attempt to fix this, I unset the ForeColor from "Black" in Visual Style Builder to allow it to overridden (I need some red labels in my form). Since, however, RadLabelElement.Disabled explicitly sets the ForeColor to "DisabledForeColor", when it is reenabled the ForeColor never goes back to black.

    To resolve this, I set RadLabelElement back to "Black" in the theme, and disabled theming on the labels I needed to be red.

    If there's a better solution, I'm all ears. In any case, thank you for your help.
  6. George
    Admin
    George avatar
    500 posts

    Posted 14 Nov 2014 Link to this post

    Hi Chris,

    Thank you for writing back.

    In order to keep the labels red in all cases you can use the following code:
    radLabel.Text = "Red Label";
    radLabel.RootElement.UseCompatibleTextRendering = false;
    radLabel.RootElement.UseDefaultDisabledPaint = false;
    radLabel.LabelElement.ForeColor = Color.Red;
    radLabel.LabelElement.RadPropertyChanged += LabelFill_RadPropertyChanged;
    ....
    void LabelFill_RadPropertyChanged(object sender, RadPropertyChangedEventArgs e)
    {
        if (e.Property.Name == "Enabled")
        {
            radLabel.LabelElement.ForeColor = Color.Red;
        }
    }

    I hope this will help.

    Regards,
    George
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for WinForms is Visual Studio 2017 Ready