Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make picturebox transparent?

I am making an application in C# .NET. I have 8 picture boxes in it. I used PNG images with transparent background but in my form it is not transparent when it comes above another image.

I am using Visual Studio 2012. This is a screenshot of my form:

Screenshot of Form

like image 982
Belal Khan Avatar asked Nov 11 '13 15:11

Belal Khan


People also ask

How do I make the background transparent in a PictureBox?

Solution 2 Follow three steps process to set the transparent color. Step 1: Locate the constructor for your control class. Step 2: In the constructor, call the SetStyle method of your form. This will enable your control to support a transparent backcolor.

How do I make an image transparent?

Double-click the picture, and when Picture Tools appears, click Picture Tools Format > Color. Click Set Transparent Color, and when the pointer changes, click the color you want to make transparent.

How do I make a group box transparent in C#?

Clear(groupBox1. TransparencyKey = Color. Red); this section of the code in my DrawGroupBox method TransparencyKey still gives me a red squiggly line. If the OP use TransparencyKey it makes the whole region of GroupBox to be transparent and you will see what is behind the form.


1 Answers

One way to do this is by changing the parent of the overlapping picture box to the PictureBox over which it is lapping. Since the Visual Studio designer doesn't allow you to add a PictureBox to a PictureBox, this will have to be done in your code (Form1.cs) and within the Intializing function:

public Form1() {     InitializeComponent();     pictureBox7.Controls.Add(pictureBox8);     pictureBox8.Location = new Point(0, 0);     pictureBox8.BackColor = Color.Transparent; } 

Just change the picture box names to what ever you need. This should return:

enter image description here

like image 151
SuperPrograman Avatar answered Oct 07 '22 13:10

SuperPrograman