在Datarepeator控件中绑定图像 [英] Binding image in Datarepeator control
问题描述
i需要将图像从sql db绑定到datarepeator控件,我可以绑定文本类型值
例如。 lblName.DataBindings.Add(Text,dt,MyName)
效果不错,但图片由
提供
Hi,
i need to bind the image to datarepeator control from sql db, i can bind text type value
eg. lblName.DataBindings.Add("Text", dt, "MyName")
working well but for image given by like
PictureBox1.DataBindings.Add("Image", dt, "photo")
它没有显示图像
任何解决方案
问候
Antony
it does not show image
any solution
Regards
Antony
推荐答案
它不显示图像
是抛出错误还是不显示图像?
无论如何,你应该在绑定中启用格式化。
Does it throw an error or does just not display the image?
In any case, you should enable formatting in the binding.
PictureBox1.DataBindings.Add("Image", dt, "photo", True)
您好b $ b
谢谢
Hi
Thank you
TnTinMn551
i尝试使用您的解决方案,即使它无法正常工作。
最后我得到了一个解决方案就是,我为该控件添加了一个事件...
i tried with your solution, even it is not working.
finally i got one solution that is, i have added one event for that control as ...
Private Sub DataRepeater1_DrawItem(ByVal sender As System.Object, ByVal e As Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs) Handles DataRepeater1.DrawItem
Try
Dim currItem As DataRowView = bs.Item(e.DataRepeaterItem.ItemIndex)
If Not IsDBNull(currItem.Item("photo")) Then
DirectCast(e.DataRepeaterItem.Controls("picturebox1"), PictureBox).Image = GetBitmap(DirectCast(currItem.Item("photo"), Byte()))
Else
DirectCast(e.DataRepeaterItem.Controls("picturebox1"), PictureBox).Image = Nothing
End If
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub
其工作效果e />
谢谢
问候
Antony
its working fine
Thanks
Regards
Antony
这篇关于在Datarepeator控件中绑定图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!