bound picture box image doesn't update...

perpetual_dream

New member
Joined
Aug 11, 2007
Messages
2
Programming Experience
1-3
Hello,
This is my first post here. Nobody else has managed to help me so far.I hope I find a solution for my prob here......

In my form I have a bound picturebox and a textbox. The Textbox data changes immediately appears after I update, yet the picturebox changed data doesn't appear unless I reload the form (This means that you can the see the picturebox up-to-date data only once). What am sure that the problem has either to do with the binding of a Image field to a picture box with bind object or PictureFormat Delegate

Here is my relevant code:

VB.NET:
Private Sub load_company_details()

Try
ds.Tables.Clear()

ds.Clear()

ds = Me.companyprovider.select_all_from_company_datatset()

Me.piccompany.DataBindings.Clear()

' Me.PictureBox1.DataBindings.Clear()

Me.txttitle.DataBindings.Clear()


Dim bind As Binding = New System.Windows.Forms.Binding("Image", ds, "company_settings.Company_Logo", True)

Dim bind2 As Binding = New System.Windows.Forms.Binding("Text", ds, "company_settings.Company_Name")

AddHandler bind.Format, AddressOf PictureFormat

Me.piccompany.Refresh()

Me.piccompany.DataBindings.Add(bind)

Me.txttitle.DataBindings.Add(bind2)
Me.piccompany.SizeMode = PictureBoxSizeMode.StretchImage
bind = Nothing

Catch ex As Exception

MsgBox(ex.Message)

End Try

End Sub

Private Sub PictureFormat(ByVal sender As Object, ByVal e As ConvertEventArgs)
' e.Value is the original value
Dim img() As Byte = CType(e.Value, Byte())
Dim ms As New MemoryStream()
Dim offset As Integer = 0
ms.Write(img, offset, img.Length - offset)
Dim bmp As New Bitmap(ms)
' Writes the new value back
e.Value = bmp
img = Nothing
bmp = Nothing
End Sub

I can c the updated changed image in the picturebox only the 1st time, it seems the binding OBJECT REMAINS THE SAME HERE..................

Dim bind As Binding = New System.Windows.Forms.Binding("Image", ds, "company_settings.Company_Logo", True)


The binding data doesn't change after 1st time
 
Back
Top