标签透明 [英] Label Transparent

查看:47
本文介绍了标签透明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想使标签在图片框上透明.
我写的代码是

Hi,

I want to make label trasparent on a picture box.
The code I have written is

label1.parent = picturebox1;// not working
label1.backcolor = color.transparent// 

即使这不起作用


在此先感谢

even this is not working


Thanks in advance

推荐答案

同时使用以下语句:
Use both statements:
this.label1.Parent = this.pictureBox1;
this.label1.BackColor = Color.Transparent;


label1.parent = picturebox1; // not working

label1.backcolor = color.transparent // even this is not working


如果出于您的目的使用相同的编码,则它将永远不会运行,因为label1不包含 parent backcolor
的定义
由于关键字区分大小写,因此请使用 Parent而不是parent BackColor而不是backcolor .

使用给定的代码


if you are same coding for your purpose then it will never run it because of label1 does not contain difinition of parent or backcolor

use Parent instead of parent and BackColor instead of backcolor because of keyword are case sensitive.

Use given code

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



它可以工作:)



it works :)




在代码中创建标签,然后将其动态添加到表单中,而不是在设计时将其拖放到表单上.

这是代码-我以构造函数的形式添加了它:

Hi,

Create a label in your code and add it to the form dynamically instead of drag-dropping it on to the form at design time.

Here''s the code - I added it in the form''s constructor method:

public HowToForm()
{
    InitializeComponent();
    Label lbl = new Label();
    lbl.Parent = pictureBox1;
    lbl.BackColor = Color.Transparent;
    lbl.ForeColor = Color.Black;
    lbl.Visible = true;
    lbl.Text = "DnG";
}



谢谢,
DnG

-------------------------------------------------- ----------------
如果您觉得有用,请记住将其标记为答案:).



Thanks,
DnG

------------------------------------------------------------------
Please remember to mark this as answer if you find it useful :).


这篇关于标签透明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆