Thanks for friends that reply my post before....
I am binding a picture box to a path... It works fine if the path is valid. Problem comes when tha path is invalid or empty...
The code that is red highlighted is where the error come out..
Private Sub BindFields()
Try
Dim b As Binding = New Binding("Image", objDView, "CoverSample")
AddHandler b.Format, AddressOf MyPictureBox_FormatImage
picBook.DataBindings.Add(b)
Catch ex As Exception
MsgBox(ex.Message, , "BindFields")
End Try
End Sub
Private Sub MyPictureBox_FormatImage(ByVal sender As Object, ByVal e As ConvertEventArgs)
Try
If Trim(e.Value.ToString) <> "" Then
Dim fi As New System.IO.FileInfo(e.Value.ToString)
If fi.Exists() Then
e.Value = Image.FromFile(e.Value.ToString)
isValidPath = True
End If
End If
Catch ex As Exception
MsgBox(ex.Message, , "MyPictureBox_FormatImage")
End Try
End SubpicBook.DataBindings.Add(b)picBook.DataBindings.Add(b)
I am binding a picture box to a path... It works fine if the path is valid. Problem comes when tha path is invalid or empty...
The code that is red highlighted is where the error come out..
Private Sub BindFields()
Try
Dim b As Binding = New Binding("Image", objDView, "CoverSample")
AddHandler b.Format, AddressOf MyPictureBox_FormatImage
picBook.DataBindings.Add(b)
Catch ex As Exception
MsgBox(ex.Message, , "BindFields")
End Try
End Sub
Private Sub MyPictureBox_FormatImage(ByVal sender As Object, ByVal e As ConvertEventArgs)
Try
If Trim(e.Value.ToString) <> "" Then
Dim fi As New System.IO.FileInfo(e.Value.ToString)
If fi.Exists() Then
e.Value = Image.FromFile(e.Value.ToString)
isValidPath = True
End If
End If
Catch ex As Exception
MsgBox(ex.Message, , "MyPictureBox_FormatImage")
End Try
End SubpicBook.DataBindings.Add(b)picBook.DataBindings.Add(b)