c# - 是否可以有两个带有透明图像的重叠 PictureBox 控件?

标签 c# .net winforms picturebox alpha-transparency

<分区>

有两个重叠 PictureBox controls ,我试图让图片框的透明区域让下面的控件(在 z 顺序中)可见。

甚至在 trying what Microsoft suggests 之后, 我得不到想要的结果。

这是我目前拥有的:

enter image description here

这就是我想要的:

enter image description here

所以我的问题是:

有什么方法可以使用两个相互重叠的 PictureBox 控件(或另一种方法)来实现我想要的结果,让透明区域透过?

更新:

其实我是用this answer解决的SO 问题“Transparent images with C# WinForms”。

最佳答案

试试这个

private void Form1_Load(object sender, EventArgs e)
{
  // Transparent background...  
  pictureBoxOverlay.BackColor = Color.Transparent;

  // Change parent for overlay PictureBox...
  pictureBoxOverlay.Parent    = pictureBoxMain;

 // Change overlay PictureBox position in new parent...
 // pictureBoxOverlay.Location  = new Point(0, 0);
}

结果

enter image description here

Link

关于c# - 是否可以有两个带有透明图像的重叠 PictureBox 控件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11412169/

相关文章:

.net - 使用 Azure ApplicationInsights 时,在哪里可以找到 TelemetryClient.TrackEvent() 的输出日志?

c# - 如何捕捉 C# .NET 窗体上的按键

c# - 在继承的 UserControl 中通过 Designer 编辑 DataGridView

c# - ListView 中的项目没有行缩进

c# - 这段代码可以避免 SQL 注入(inject)吗? (以及为什么)

C# 数组与泛型列表

.net - 输入键触发错误的提交按钮

c# - 使用集线器对广播消息进行信号量表测试

C#从目录中获取所有没有扩展名的文件名

c# - 反序列化压缩字符串时出错(解析完成前遇到流结束)C#