vb中图片框透明度

发布于 2025-01-07 01:10:09 字数 53 浏览 4 评论 0原文

当我运行代码时,图片框具有背景颜色,即使我已在属性窗口中将背景颜色设置为透明。有什么想法吗?

When i run my code, the picture box has a background colour, even though I have set the background colour to transparent in the properties window. any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

樱花坊 2025-01-14 01:10:09

我假设您将 PictureBox 重叠在其他一些控件上,并希望看透 PictureBox。这不是它的工作原理 - 具有透明背景的控件仅相对于其父控件是透明的,而不是其他控件。您可以通过覆盖表单的 OnPaint 方法来使用 GDI+ 绘制它们:

Private Shared ReadOnly SomeImage As Image = My.Resources.blah 'Get your image somewhere

Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
    Dim g As Graphics = e.Graphics

    g.DrawImage(SomeImage, xCoordinate, yCoordinate)

    'Draw as many images or text as you want.
End Sub

此外,似乎人们主要是在寻找此功能来制作游戏。你在做游戏吗?如果是这种情况,请在制作游戏之前学习图形。那里有很多很好的教程。

I assume you're overlapping a PictureBox over some other control and expecting to see through the PictureBox. That's not how it works - controls with transparent backgrounds are only transparent relative to their parent, not other controls. You could draw them using GDI+ by overriding the OnPaint method of your form:

Private Shared ReadOnly SomeImage As Image = My.Resources.blah 'Get your image somewhere

Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
    Dim g As Graphics = e.Graphics

    g.DrawImage(SomeImage, xCoordinate, yCoordinate)

    'Draw as many images or text as you want.
End Sub

Also, it seems that people are mostly looking for this functionality to make a game. Are you making a game? Please learn graphics before making a game if this is the case. There are many good tutorials out there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文