Transparent controls in .NET - c#

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

Related

C# winforms transparent form overlay issue

My main form has a horizontal splitcontainer on it. The top portion contains an Object List View control found here.
I am using code from a previous C# transparent overlay form answer.
My issue seems to have something to do with the Object List View. Using the code from the answer above, the transparent form covers all controls perfectly, however when it gets to the Object List View it seems to draw darker over this specific control.
If I close the transparent overlay and bring a blank panel to the front, when I open the transparent overlay, it still shows this darker section as if the object list view control is still visible.
I would first like to know why this is happening. But I would also like to know how I can fix this so that the overlay is consistant.
In case you wish to test this I created a simple project to demonstrate the issue here
To replicate what happens...
Drag the splitcontainer down a little and click the Overlay button.
Close the overlay by clicking in the White Panel. Click the Blank Panel button then click the Overlay button again.
Please note that in the Plexiglass class, it is taking a panel as a parameter only for the sake of this demonstration, in my actual project, it takes the main form as a parameter.
EDIT
I changed the color from dark gray to white and it works perfectly. I am not sure why the dark gray was causing that issue, but I am pleased with the way it looks with white so I will stick with that.
For some reason, the Color.DarkGray BackColor attribute for the transparent form was causing the issue. Changing the BackColor to Color.White fixed this.
Thanks to Patrice Gahide for helping me.

Don't use backcolor on a label but still use a background from its parent

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.

Form background color or image stuck as white

I started teaching myself C# a week ago. I started by writing Tetris to get myself acquainted with the language. I got the main game mechanics working by painting onto presized bitmap and displaying it in a picturebox, which at the time was the same size of the window. Now I have expanded the windows size and started adding other controls to the side of the picture box.
The problem is, now that I have expanded the window, displaying the form background, the background color is permanently white or I get a weird white to black faded look in the bottom corner.
I have tried several things:
- set the form backcolor manually, but it is only reflected on the labels
- checked that the transparencykey is empty
- set transparencykey to an unused color, nothing changes - added a bmp as the form's background image, still stays white - checked my code to see if I was every writing directly to the form background
I can't fingure out how to fix this; does anyone have any ideas?
EDIT: I found the answer to my question. SetStyle(ControlStyles.Opaque, true) was called in my constructor. I'm not sure what exactly that does, but I commented it out and it fixed my problem.
Please list out the requirements means exactly what you need?
After I read your question. The following are my understandings.
If your problem is with changing window size, then
make use of Split container, which is
available in toolbox from
'Containers' group.
set its Dock property to fill to
fill entire window if
resized/maximized.
Then use the right pane to contain your picture box and left pane for other controls.
If you require, you may also set dock property of picture box to fill to its parent container means right pane.
If your problem is with background color of the window, then
Actually Background color issue comes, If the form is an Mdi Container.
Check whether IsMdiContainer property is set to false. If true it is an MdiContainer.
The following code block sets Mdi Forms' backcolor to the forms' backcolor.
foreach (Control c in this.Controls)
{
if (c is MdiClient)
{
c.BackColor = this.BackColor;
}
}
I found the answer to my question. SetStyle(ControlStyles.Opaque, true) was called in my initialization. I'm not sure what exactly that does, but it was the cause of my background color issue.

Shadow to windows form

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

How to make the form completely transparent

I already made the background transparent but there is still some part left from the group box. How do I make those transparent also?
The blank line are what I want it to be transparent. It should give you the picture of what I want. Thanks.
And don't even ask what are the password for, all of them are just dummies :)
If you want to see and edit the code, here
That's just how the GroupBox control works. The Background property of that control includes the area that your screenshot points to. If you wanted to do a workaround for it, you should set the GroupBox background to be transparent as well, and draw a white box behind it, encompassing only the area you want to be white.
Form.Opacity doesn't work for you?
What is the GroupBox's parent container? Is it a Form or a Panel? Is that element also set to transparent? As a test I made a GroupBox and placed it on top of (inside) a Panel. I changed the background color of the Panel to red and the background color of the GroupBox to transparent and those ares of the GroupBox are properly transparent. My suggestion is to look at the parent container.
Also the GroupBox label may become hard to read in some cases, once the top strip is transparent.

Categories

Resources