[C#] How to make a label background transparent if the formis semi transparent? RRS feed

  • Question

  • My problem is that I have a semi transparent form using this code:

    protected override void OnPaintBackground(PaintEventArgs e)
                var sb = new SolidBrush(Color.FromArgb(50, 0, 0, 0));
                e.Graphics.FillRectangle(sb, this.DisplayRectangle);

    and I want to have a label on that form that has a the same semi transparent background as the form itself. I tried multiple things but the label appears pitch black all the time. What is the solution to this?


    Friday, April 12, 2019 3:03 PM

All replies

  • Set Opacity of the Form to 50%, or other value, instead.
    Friday, April 12, 2019 8:26 PM
  • Hi Siratox,

    Just as Castorix31 said, you can try to set the form's Opacity to "0.5":

        private void Form1_Load(object sender, EventArgs e)
            this.Opacity = 0.5;

    In this way, the label will have the same transparency.



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    • Marked as answer by XzerT Tuesday, April 16, 2019 9:02 AM
    • Unmarked as answer by XzerT Tuesday, April 16, 2019 9:18 AM
    Monday, April 15, 2019 3:03 AM
  • Ok that works but it also makes the text of the label 50% transparent... Is there a way to get around this?



    • Edited by XzerT Tuesday, April 16, 2019 9:20 AM
    Tuesday, April 16, 2019 9:19 AM