包含 PictureBox 的面板在背景更改时闪烁。我怎样才能消除这个问题?
我有一个带有背景图像集的面板,我将其用作按钮。该面板还包含一个 PictureBox,其中加载了 png 图像,以便图像的某些部分是透明的并且面板图像可以透过。在 MouseDown 上我更改了面板背景图像,然后在 MouseUp 上我再次将其更改回来。问题是,当面板图像发生变化时,PictureBox 在重新绘制其透明区域时会严重闪烁。
我尝试使用其 on 形式的 DoubleBuffered 属性;那里没有运气。我还在更改图像之前尝试过 SuspendLayout,刷新 PictureBox,然后 ResumeLayout。还是没有运气。
预先感谢您的任何想法。
I have a panel with the BackgroundImage set that I'm using as a button. The panel also contains a PictureBox with a png image loaded so that parts of the image are transparent and the panel image shows through. On MouseDown I change the panels BackgroundImage, then on MouseUp I change it back again. The problem is that when the panel image changes, the PictureBox flickers badly when redrawing its transparent areas.
I've tried using the DoubleBuffered property of the form its on; no luck there. I've also tried SuspendLayout just before changing the image, refreshing the PictureBox, then ResumeLayout. Still no luck.
Thanks in advance for any ideas.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是VS在图形方面不好的地方。尝试使用 Form
BackgroundImage
属性,或重写OnPaint
事件并使用Graphics
类手动绘制图像(在 Form 上绘制)。It's the bad part of VS in graphic. Try using Form
BackgroundImage
property, or overridesOnPaint
event and useGraphics
class to draw the image manually (draw on the Form).