2013-01-08 99 views
3

我想提出兩個或多個重疊PictureBox透明背景,但如果我這樣做我只看到一個圖片:重疊PicuresBox與透明背景

enter image description here

我創建這樣我PictureBox ES:

PictureBox pb1 = new PictureBox(); 
pb1.Size = new Size(32, 32); 
pb1.Location = new Point(0,0); 
pb1.Image = Image.FromFile("../Graphics/Grounds/ground.png"); 
pb1.Visible = true; 

PictureBox pb2 = new PictureBox(); 
pb2.Size = new Size(32, 32); 
pb2.Location = new Point(0,0); 
pb2.Image = Image.FromFile("../Graphics/Grounds/human.png"); 
pb2.Visible = true; 

稍後我將這兩個PictureBox es添加到我的Panel

panel1.Controls.Add(pb1); 
panel1.Controls.Add(pb2); 

那麼爲什麼它只顯示一個PictureBox

+0

可能HTTP的副本:// stackoverflow.com/questions/5522337/c-sharp-picturebox-transparent-background-doesnt-seem-to-work –

+3

看看這個答案:http://stackoverflow.com/a/9158849/838405 –

回答

-1

如果您human.png具有透明背景:

pb2.BackColor = Color.Transparent; 
+1

不,主要問題這是人類的電影箱應該作爲groundPicBox的子控件插入,如http://stackoverflow.com/a/9158849/838405和Hans Passant的答案中所述 –

0

嘗試改變panel1.Controls.Add(pb2);pb1.Controls.Add(pb2);
請務必設置正確的位置pb1是容器