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.
我有一个带有BackgroundImage设置的面板,我将其用作按钮。该面板还包含一个PictureBox,其中加载了png图像,以使图像的某些部分透明,并显示面板图像。在MouseDown上我更改面板BackgroundImage,然后在MouseUp上我再次更改它。问题是当面板图像发生变化时,PictureBox在重绘其透明区域时会闪烁不良。
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.
我已经尝试使用其上的表单的DoubleBuffered属性;那里没有运气。我在更改图像之前尝试过SuspendLayout,刷新PictureBox,然后刷新ResumeLayout。仍然没有运气。
Thanks in advance for any ideas.
提前感谢任何想法。
1 个解决方案
#1
2
It's the bad part of VS in graphic. Try using Form BackgroundImage
property, or overrides OnPaint
event and use Graphics
class to draw the image manually (draw on the Form).
这是VS在图形中不好的部分。尝试使用Form BackgroundImage属性,或覆盖OnPaint事件并使用Graphics类手动绘制图像(在Form上绘制)。
#1
2
It's the bad part of VS in graphic. Try using Form BackgroundImage
property, or overrides OnPaint
event and use Graphics
class to draw the image manually (draw on the Form).
这是VS在图形中不好的部分。尝试使用Form BackgroundImage属性,或覆盖OnPaint事件并使用Graphics类手动绘制图像(在Form上绘制)。