lily.core 支持图片的方式及ultragrid绑定时显示图片

2014年2月13日

Private md_图片 As Byte()
<Browsable(True)> _
Public Overridable Property 图片() As Byte()
Get
Return md_图片
End Get
Set(ByVal Value As Byte())
md_图片 = Value

                Me.OnPropertyChanged(“图片”) 注意此不能需要

End Set
End Property

 

映射实体字段dbtype类型是 DbType.Binary

 

绑定ultragrid后如何显示图片

Case item._图片.AttributeName

Dim imgEditor As New EmbeddableImageRenderer()
‘ Give the images a slim grayish border and align them to be in the middle of the cell.
imgEditor.BorderShadowColor = Color.FromArgb(255, 128, 128)
imgEditor.BorderShadowDepth = 2
With e.Layout.Bands(0).Columns(item._图片.AttributeName)
.Editor = imgEditor
.CellAppearance.ImageHAlign = HAlign.Center
.CellAppearance.ImageVAlign = VAlign.Middle
End With

如何实时添加或移除图片

”’ <summary>
”’ 清除图片
”’ </summary>
”’ <remarks></remarks>
Public Overridable Sub ClearPicture()
Dim o As New Lily.Core.Operate
Dim strsql As String = “update ” & Me.TableName & ” set 图片=null where id=” & Me.ID
o.ExecuteNonQuery(strsql, CommandType.Text)
Dim buffer(0) As Byte
Me.图片 = buffer
End Sub

 

 

‘写入数据库
Dim strsql As String = “update ” & Me.TableName & ” set 图片=@文件内容 where id=” & Me.ID
Dim par As New SqlClient.SqlParameter
par.ParameterName = “@文件内容”
par.DbType = DbType.Binary
par.Value = byt

o.ExecuteNonQuery(strsql, CommandType.Text, par)

Me.图片 = byt

 

声明: 本文采用 BY-NC-SA 协议进行授权. 转载请注明转自: lily.core 支持图片的方式及ultragrid绑定时显示图片
本文的评论功能被关闭了.