Bel*_*han 22 c# picturebox winforms
我在C#.NET中创建一个应用程序.我有8个图片框.我使用了具有透明背景的PNG图像,但在我的形式中,当它出现在另一个图像上方时它是不透明的.
我正在使用Visual Studio 2012.这是我的表单的屏幕截图:

Sup*_*man 55
一种方法是将重叠图片框的父级更改为它所研究的PictureBox.由于Visual Studio设计器不允许您将PictureBox添加到PictureBox,因此必须在代码(Form1.cs)和Intializing函数中完成:
public Form1()
{
InitializeComponent();
pictureBox7.Controls.Add(pictureBox8);
pictureBox8.Location = new Point(0, 0);
pictureBox8.BackColor = Color.Transparent;
}
Run Code Online (Sandbox Code Playgroud)
只需将图片框名称更改为您需要的名称即可.这应该返回:

GameBoard是DataGridView类型的控件; 图像应为具有透明alpha通道背景的PNG类型;
Image test = Properties.Resources.checker_black;
PictureBox b = new PictureBox();
b.Parent = GameBoard;
b.Image = test;
b.Width = test.Width*2;
b.Height = test.Height*2;
b.Location = new Point(0, 90);
b.BackColor = Color.Transparent;
b.BringToFront();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
110283 次 |
| 最近记录: |