装订图片框 [英] Binding Picture box
本文介绍了装订图片框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道我们是否可以像这样绑定一个图片框:
I want to know if we can bind a picturebox as this example :
Binding b = new Binding("Image", dataset, "Timage.imagee");
pictureBox1.DataBindings.Add(b);
推荐答案
尝试使用Binding对象的Format事件:
Try using the Format event of the Binding object:
Binding b = new Binding("Image", dataset, "Timage.imagee", true);
b.Format += picFormat;
pictureBox1.DataBindings.Add(b);
private void pic_Format(object sender, ConvertEventArgs e)
{
Bitmap bmp = null;
byte[] img = (byte[])e.Value;
using (MemoryStream ms = new MemoryStream()) {
ms.Write(img, 0, img.Length);
bmp = new Bitmap(ms);
}
if (bmp != null) {
e.Value = bmp;
}
}
这篇关于装订图片框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文