PictureBox控件是否有图像更改的事件? [英] Is there an event for an image change for a PictureBox Control?
问题描述
如何知道图片框的图像何时发生变化?
图像是否有变化?
首先确保图像被异步加载。为此,请设置PictureBox的 WaitOnLoad属性 false(这是默认值)。
pictureBox1.WaitOnLoad = false;
然后异步加载图像:
pictureBox1.LoadAsync( neutrinos.gif);
为PictureBox的LoadCompleted事件创建事件处理程序。异步映像加载操作完成,取消或导致异常时触发此事件。
pictureBox1.LoadCompleted + = PictureBox1_LoadCompleted;
pre>
private void PictureBox1_LoadCompleted(Object sender,AsyncCompletedEventArgs e)
{
// ...
}
您可以在MSDN上找到有关此活动的更多信息:
How do I know when the image of the picturebox change?
Is there an event for an image change?解决方案First make sure that the images are loaded asynchronously. To do this set the PictureBox's WaitOnLoad property to false (which is the default value).
pictureBox1.WaitOnLoad = false;
Then load the image asynchronously:
pictureBox1.LoadAsync("neutrinos.gif");
Create an event handler for the PictureBox's LoadCompleted event. This event is triggered when the asynchronous image-load operation is completed, canceled, or caused an exception.
pictureBox1.LoadCompleted += PictureBox1_LoadCompleted; private void PictureBox1_LoadCompleted(Object sender, AsyncCompletedEventArgs e) { //... }
You can find more information about this event on MSDN:
http://msdn.microsoft.com/en-us/library/system.windows.forms.picturebox.loadcompleted.aspx
这篇关于PictureBox控件是否有图像更改的事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!