如何刷新图片框
我没什么问题要问。
假设我在 pictureBox 上写了一个椭圆,然后单击了一个按钮。我希望 pictureBox 能够自行刷新。
我尝试过PictureBox.Invalidate()
,但无法成功。 我最诚挚的问候...
I've little question to ask.
Let's say I've written an ellipse on pictureBox, then clicked a button. I want pictureBox to refresh itself.
I've tried PictureBox.Invalidate()
, but could'nt made it.
My best regards...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试方法
PictureBox.Refresh()
(继承自Control
)。Try the method
PictureBox.Refresh()
(inherited fromControl
).您尝试过
PictureBox.Update();
吗?或者尝试这样的http://msdn。 microsoft.com/en-us/library/system.windows.forms.picturebox.image.aspxHave you tried
PictureBox.Update();
? Or try something like this http://msdn.microsoft.com/en-us/library/system.windows.forms.picturebox.image.aspx有几种方法可以更新 PictureBox,如果有一些延迟,您使用的方法会有所不同。我有一个程序,可以在 PictureBox 中绘制键入的字符,并且击键处理很慢,因此当我快速键入时,它会滞后。
如果我
pictureBox.Refresh() ;
每次击键后,无论如何都会在处理击键后立即刷新图片。这样,当我快速打字时,我可以看到 PictureBox 试图赶上我,因为它绘制了每个字符。如果我
pictureBox.Invalidate( );
,那么也会刷新图片,但前提是系统有一些空闲时间。这样,当我快速打字时,当系统试图赶上时,我看不到任何事情发生,然后我输入的所有内容突然出现。通常刷新会更好,但这里一篇文章描述了几种情况,其中Invalidate是更好的选择。
There are a couple ways to update the PictureBox, and the method you use makes a difference if you have some lag. I had a program that drew typed characters in a PictureBox, and the keystroke processing was slow so when I typed fast it would lag.
If I
pictureBox.Refresh();
after each keystroke, then that refreshes the picture immediately after the keystroke is processed, no matter what. This way, when I typed fast I could see the PictureBox trying to catch up with me as it drew each character.If instead I
pictureBox.Invalidate();
, then that refreshes the picture too, but only when the system has some free time. This way, when I typed fast I saw nothing happening while the system tried to catch up, and then everything I'd typed suddenly appeared.Usually Refresh is better, but here's an article that describes a couple situations where Invalidate is the better choice.