Public Class BindingPictureBoxClass BindingPictureBox Inherits System.Windows.Forms.PictureBox Protected Overrides Sub OnPaint()Sub OnPaint(ByVal pe As System.Windows.Forms.PaintEventArgs) If Not IsNothing(Me.Image) Then Dim Width As Integer = Me.Image.Width Dim heigh As Integer = Me.Image.Height Dim nWidth, nHeigh, posx, posy As Integer Dim p As Double = Me.Width / Me.Height If (Width / heigh) > p Then nWidth = Me.Width nHeigh = Convert.ToInt32(Me.Width / Width * heigh) Else nHeigh = Me.Height nWidth = Convert.ToInt32(Me.Height / heigh * Width) End If posx += (CInt(Me.Width - nWidth) /2) posy += (CInt(Me.Height - nHeigh) /2) pe.Graphics.DrawImage(Me.Image, posx, posy, nWidth, nHeigh) End If End Sub Public Property ImageMember()Property ImageMember() As Object Get If IsNothing(Me.Image) Then Return DBNull.Value Else Dim img As Image = Me.Image Dim ST As New IO.MemoryStream Dim RD As New IO.BinaryReader(ST) img.Save(ST, Imaging.ImageFormat.Jpeg) Dim buff As [Byte]() = ST.ToArray ST.Close() If buff.Length >1 Then Return buff Else Return (DBNull.Value) End If End If End Get Set(ByVal Value As Object) If Not IsDBNull(Value) Then Dim Buff As [Byte]() = CType(Value, Byte()) If Buff.Length >1 Then Dim ST As IO.MemoryStream = New IO.MemoryStream(Buff) Me.Image = Image.FromStream(ST) Me.Invalidate() ST = Nothing End If Else Me.Image = Nothing Me.Invalidate() End If End Set End Property End Class