I NEED TO have a trance parent back ground in my windows form application,but when i try to set the background color to transe parent,it says "invalid property".
so how do i set my back ground to tranceparent in VS2008

In Design View, set your form's TransparencyKey to Magenta, then set the form's Background property to Magenta. When you run your program, anything set to Magenta will appear transparent.

no that not what i need to have,
what i need to be transparent is the area that i have highlighted with red color.@ the image,

That image is a windows form that has set the bored property to non.

Attachments a.jpg 115.51 KB

I'm assuming that you're setting that image to the BackgroundImage property of the form? If so, like I said, just set the BackColor and TransparencyKey to Magenta. It seems the transparent areas of the image you're using are showing the Control colour from underneath it, which is good, as it will allow the Magenta to show through. Please keep in mind that the image will have to be using a 1-bit alpha channel (ie. either a pixel is transparent or it's not, no semi-transparency). However, if you must have a full 8-bit alpha channel, you'll need to make your form layered by setting its window style to WS_EX_LAYERED by overriding its CreateParams property. This comes with a few downfalls, though, as you'll need to override the OnPaint method and draw the controls yourself.

Edited 6 Years Ago by Yamachi: n/a

@ chathu D

i'm assuming that form(including borders) has to be made transparent,so that, form or window that is behind the main form can be seen.

for this :try changing the opacity level in the form properties.

50% = half transparent.
0% = completely transparent

Is the image in the forms Background property like Yamachi assumed?
Is it the forms background showing through the image that gives the unwanted grey border?
What do you get when you set the forms backcolor to Magenta (with TransparencyKey reset to default)?
Does the grey border change to Magenta?
@shelly1234: Changing opacity will affect the whole form, including all the controls on it.

Edited 6 Years Ago by nick.crane: n/a

I tried your project (in VS2010) and after setting the logging form BackgroundImage to Untitled-1.gif the forms background border was transparent as expected.
Note: This is because Untitled-1.gif has its border color(white) marked as a transparent.
(It still had the frame as you had not set the FormBorderStyle to none).

What do you see?
What did you mean by "its not working dude"?

I'm assuming that you're setting that image to the BackgroundImage property of the form? If so, like I said, just set the BackColor and TransparencyKey to Magenta. It seems the transparent areas of the image you're using are showing the Control colour from underneath it, which is good, as it will allow the Magenta to show through. Please keep in mind that the image will have to be using a 1-bit alpha channel (ie. either a pixel is transparent or it's not, no semi-transparency). However, if you must have a full 8-bit alpha channel, you'll need to make your form layered by setting its window style to WS_EX_LAYERED by overriding its CreateParams property. This comes with a few downfalls, though, as you'll need to override the OnPaint method and draw the controls yourself.

thanx for trying my project. and this is what i say "it is not working dude" (for seting the BackColor and TransparencyKey to Magenta)

What do you see if you reset the BackgroundImage to none?
(With BackColor and TransparencyKey set to Magenta)

This article has been dead for over six months. Start a new discussion instead.