How to do a background for a label will be without color?

后端 未结 5 597
情书的邮戳
情书的邮戳 2020-12-30 23:00

I want to add a label to my form , and I want it without any color- I want just it\'s text to be visible, I don\'t find this option in the label\'s properties, can anyone he

相关标签:
5条回答
  • 2020-12-30 23:45

    If you picture box in the background then use this:

    label1.Parent = pictureBox1;
    label1.BackColor = Color.Transparent;
    

    Put this code below InitializeComponent(); or in Form_Load Method.

    Ref: https://www.c-sharpcorner.com/blogs/how-to-make-a-transparent-label-over-a-picturebox1

    0 讨论(0)
  • 2020-12-30 23:46
    this.label1.BackColor = System.Drawing.Color.Transparent;
    
    0 讨论(0)
  • 2020-12-30 23:46

    You are right. but here is the simplest way for making the back color of the label transparent In the properties window of that label select Web.. In Web select Transparent :)

    0 讨论(0)
  • 2020-12-30 23:47

    Do you want to make the label (except for the text) transparent? Windows Forms (I assume WinForms - is this true) doesn't really support transparency. The easiest way, sometimes, is Label's Backcolor to Transparent.

    label1.BackColor = System.Drawing.Color.Transparent;
    

    You will run into problems though, as WinForms really doesn't properly support transparency. Otherwise, see here:

    http://www.doogal.co.uk/transparent.php

    http://www.codeproject.com/KB/dotnet/transparent_controls_net.aspx

    http://www.daniweb.com/code/snippet216425.html

    Setting the parent of a usercontrol prevents it from being transparent

    Good luck!

    0 讨论(0)
  • 2020-12-30 23:48

    Generally, labels and textboxes that appear in front of an image is best organized in a panel. When rendering, if labels need to be transparent to an image within the panel, you can switch to image as parent of labels in Form initiation like this:

    var oldParent = panel1;
    var newParent = pictureBox1;
    
    foreach (var label in oldParent.Controls.OfType<Label>())
    {
        label.Location = newParent.PointToClient(label.Parent.PointToScreen(label.Location));
        label.Parent = newParent;
        label.BackColor = Color.Transparent;
    }
    
    0 讨论(0)
提交回复
热议问题