使用C#将mdi父窗体的图像设置为背景颜色到Windows应用程序中的标签控件 [英] Set the image of mdi parent form as back color to label control in windows app using C#

查看:476
本文介绍了使用C#将mdi父窗体的图像设置为背景颜色到Windows应用程序中的标签控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用c#开发一个Windows应用程序。我有一个mdi父表单,其中有一个标签控件。我已经通过代码更改了表单的背景图像。我还编写了使标签透明的编码,但它没有得到给定图像的背面颜色。如果我写回标签颜色= form.back颜色然后它给出在属性中设置的背面颜色,例如蓝色,白色等。

我希望标签应该是完全透明的,即怎么能我将mdi表单的图像设置为标签控件的背面颜色,或者任何其他控件。



我该怎么做.... ??? >


在此先感谢..... !!!



我尝试了什么:



在表单加载事件中,我编写了以下代码: -

 label1.Parent = this; 
label1.BackColor = this.BackColor;

解决方案

我很确定你需要这一行:

 label1.BackColor = Color.Transparent; 



而不是:

< pre lang =C#> label1.BackColor = this .BackColor;





更多信息:使用方法Windows窗体中的透明图像和标签 [ ^ ]


I am developing a windows app using c#. I have a mdi parent form in which there is a label control on it. I have changed the background image of the form through code. I have also coded for making the label transparent but it doesn't get the back color of the image given. if I write label back color = form.back color then it gives the back color which is set in properties eg blue, white, etc.
I want that the label should be fully transparent, i.e. how can I set the image of mdi form as back color of label control or else any other control.

How can I do this....???

Thanks in Advance.....!!!

What I have tried:

In form load event I have written the following code :-

label1.Parent = this;
label1.BackColor = this.BackColor;

解决方案

I'm pretty sure you need this line:

label1.BackColor = Color.Transparent;


instead of:

label1.BackColor = this.BackColor;



More at: How to Use Transparent Images and Labels in Windows Forms[^]


这篇关于使用C#将mdi父窗体的图像设置为背景颜色到Windows应用程序中的标签控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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