I have tried many ways to have a transparent background on my form. Transparency key does work, but problems arise when you put images that have opacity. I tried to override OnPaintBackground
which only removed my background image. And I tried the SetStyle
method.
Asked
Active
Viewed 1,556 times
0

Sergey Berezovskiy
- 232,247
- 41
- 429
- 459

user2081191
- 15
- 4
-
Is the problem only the image or the entire form background. – Mike C. Feb 17 '13 at 19:59
-
The issue is with the form background. I want it transparent. Also, I'm on visual studio 2012. – user2081191 Feb 17 '13 at 20:02
-
If the image contains pixels that are *partially* transparent then you cannot use it. It changes the color of the transparency key and makes it visible. Usually shows up as a colored fringe. No workaround for that, other than fixing the image. – Hans Passant Feb 17 '13 at 20:57
2 Answers
2
Assuming you are using windows forms, try:
this.TransparencyKey = Color.Red;
this.BackColor = Color.Red;
when you have a color on the form which is the same as your transparency key, then it will be transparent. on the other hand, by that the red color is assigned for transparency only, you won't be able to use it.
(and this
refers to the form)

eyossi
- 4,230
- 22
- 20
-
As I said in before, this method works, but not well with opacity images. – user2081191 Feb 17 '13 at 20:29
0
You can set opacity of the form.100% is default for Windows form and lower values are more transparent.

sadegh saati
- 1,168
- 1
- 13
- 24
-
This make the whole form transparent. I just want the background transparent. – user2081191 Feb 17 '13 at 20:30
-
The solution eyossi offered works, but not the way I wanted. I already know the method he said, but when you have images with opacity the background color is altered in the affected area. Therefor no longer being transparent. – user2081191 Feb 17 '13 at 20:58