I am working in C# Windows Forms Application
I want to make shadow of my form, so I have taken a image having shadow and set it as Form's Background image and also set TransparentKey to Form's BackColor i.e. Control Color, so that it will transparent the area which contains Control color and FormBorderStyle to None.
My problem is that I am not getting the shadow transparent, it is of Control Color.
Updated: I also want to change shape of my form
I would use this technique instead; it worked beautifully for me.
Drop shadow in Winforms Controls?
Update:
Changing the shape of a form is easier than you'd think.
Follow this tutorial: http://www.codegod.de/WebAppCodeGod/creating-custom-shapes-for-forms-in-windows-forms-AID377.aspx
Related
I am making app in Windows Forms. I've added MenuStrip and changed it colors using ToolStripProfessionalRenderer. The problem is that whenever I am trying to change dropdown border color it only changes the outside border ( image below ).
How can I change the remaining white border that still is visible inside? Or how to just disable border there?
All you have to do is to override properties that you need to set the color.
This article will help you to do that.
And this is another link about how to implement your class
HK
I have a System.Windows.Forms.ToolStrip which contains a Label.
The ToolStrip has a special fancy background. But the label is just gray.
It's not possible to use transparency because the parent of ToolStrip is a form. Also it's not possible to change the parent, because the collection of Controls in ToolStrip is read only.
Is it possible to create a Label that is transparent and which has a ToolStrip parent?
Give the following a shot.
Set the backcolor of the label to Color.Transparent.
Then you have to add the label directly to the control collection of the control of which you want the label to appear transparent on top of.
If you just delete the assigned background color of the ToolStripLabel then it ought to inherit the background of its parent ToolStrip. I use a custom ToolStripRenderer to draw a customized background for tool strips, and my labels do not need any special handling in order to inherit the parent's background. Just make sure you aren't trying to assign a background color.
If we set the background of any UI as transparent, it doesn't show what's beneath that, meaning any UI or containers. Instead, it shows the default background of the Form, the lowermost, that is.
How do I get around this transparency problem?
This is by design, unfortunately:
http://support.microsoft.com/kb/943454
Transparent controls in WinForms are transparent relative to their
parent, not to other controls. Transparency in WinForms is more akin
to camouflage than true transparency. A transparent control doesn’t
actually let you see the control behind it through the form. It asks
its parent to draw its own background on the "transparent" control.
This is why a transparent control shows the form behind it, but covers
up any other controls.
There is some code in the link that demonstrates a work around.
Windows Forms controls do not support true transparency. The background of a transparent Windows Forms control is painted by its parent.
To give your control a transparent backcolor
This will enable your control to support a transparent backcolor.
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.BackColor = Color.Transparent;
I have a problem with:
BackColor = Color.Transparent;
It's not working correctly. I have a form with a blue background, and a picturebox with a picture loaded in it. It's not actually taking what's in the picture, but rather - the form's background color. Please tell me there's a simple way to go around this?
What you see in the following screenshot is a custom usercontrol with it's backColor set to transparent, on top of a picture, in a form with a blue background.
I need the usercontrol to display what's UNDER it, as real transparency, it should be showing the gradient and part of the image.
Try setting the picture box to be the parent of the custom user control.
myControl.Parent = this.myPictureBox;
Try calling "SetStyle(ControlStyles.SupportsTransparentBackColor, true);" on your user control constructor.
more details at: http://msdn.microsoft.com/en-us/library/wk5b13s4(v=vs.90).aspx
Assume that I have a panel, this panel has a background image. I add a label to this panel. Anyone can help me how to show label's text but don't show label's backcolor, the label will inherit background image from its parent. I use a transparent backcolor on label but not effect.
Note: WinForm.
Thanks.
Using a transparent background color should work.
Note that the windows forms designer doesn't honor transparency, but at runtime it should displayed as expected.
Make sure you use the Web.Transparent color, it tends to work better.
Select your label and go to it's Properties > Backcolor > Click the Web tab > Transparent.
If you need more specific directions, please ask.