本文介绍了为什么picturebox image属性绑定后不会刷新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我的情况很简单:
-表格
-以某种方式更改pictureBox1的按钮
-picturebox1(带有一些图像)
-picturebox2(干净)
-在Form_Load中添加以下行:
绑定b = new Binding("Image",pictureBox1,"Image");
pictureBox2.DataBindings.Add(b);

一开始,我就会在两个屏幕上看到相同的图像...好!
但是,当我更改picturebox1时,picturebox2并没有跟随我...我需要刷新它!为什么?如果我正确理解绑定"技术,则在绑定属性后,我想忘记picturebox2,而只需修改picturebox1.有没有办法让make picturebox1自动刷新?有点像是一个事件(我还没有找到它!),它告诉绑定源已更改...

最好,谢谢.

Hi,
my scenario is very simple:
- a form
- a button to change somehow pictureBox1
- picturebox1 (with some image)
- picturebox2 (clean)
- into Form_Load I add these lines:
Binding b = new Binding("Image", pictureBox1,"Image");
pictureBox2.DataBindings.Add(b);

As soon as I start, I see the same images on both...OK!
But then, when I change picturebox1, picturebox2 does not follow me... I need to refresh it! Why? If I correctly understand "Binding" technology, once the property is bound, I''d like to forget picturebox2 and just modify picturebox1. Is there a way to obtain make picturebox1 autorefresh? Somethink like an event (I did not find it yet!) who tells binding source has changed...

Thanks, best.

推荐答案

private void pictureBox2_Paint(object sender, PaintEventArgs e)
{
    base.OnPaint(e);
    pictureBox1.Image = pictureBox2.Image;
}


这篇关于为什么picturebox image属性绑定后不会刷新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 23:44