Click here to Skip to main content
15,906,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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;
Posted
Updated 2-Jan-17 19:51pm

1 solution

I'm pretty sure you need this line:
C#
label1.BackColor = Color.Transparent;

instead of:
C#
label1.BackColor = this.BackColor;


More at: How to Use Transparent Images and Labels in Windows Forms[^]
 
Share this answer
 
Comments
Ank_ush 3-Jan-17 3:56am    
the form I am telling is MDI Parent not the normal form. the code you suggested, label1.BackColor = Color.Transparent;, I tried that also but when then the color of label is Dark Grey which is the color when isContainer property of form is set to true.
Maciej Los 3-Jan-17 4:00am    
That's how a transparency works! You can see what color is under that label.
Ank_ush 3-Jan-17 4:04am    
The color of label is DarkControl and there is image in form at runtime, so it doesn't look good or doesn't match

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900