'C# Textlabel Fade in/out

I am looking to have a textlabel fade in and out on a button press. I notice that textlabel does not have an opacity parameter. Is there another way that I can achieve the desired result ?



Solution 1:[1]

There is no support for Control Opacity in Winform.

In .Net Framework only Form is capable of showing opacity property, Controls on the Form have same Opacity to that of parent Form.

Solution 2:[2]

To fade a monochrome text label in/out, I have successfully used a timer to read the ForeColor of the label, scale the R component as required, then set a new ForeColour. E.g. to fade out:

    private void LabelFader_Tick(object sender, EventArgs e)
    {
        var colour = myLabel.ForeColor;
        byte cR = colour.R;

        if (cR < 210) // Set whatever limit you want, 0-255
            cR++; // cR-- to fade in
        else
            labelFader.Stop();
        myLabel.ForeColor = Color.FromArgb(255, cR, cR, cR);
    }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Parimal Raj
Solution 2