我希望使用透明背景制作两个或更多重叠的PictureBox
,但如果我这样做,我只会看到一张图片:
我创建我的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 :(得分:0)
尝试将panel1.Controls.Add(pb2);
更改为pb1.Controls.Add(pb2);
确保将pb1
设置为正确的位置
答案 1 :(得分:-1)
如果你的human.png有透明背景:
pb2.BackColor = Color.Transparent;